%a load puntos gscatter(puntos(1,:), puntos(2,:), targetsPuntos) %b t = fitctree(puntos', targetsPuntos'); view(t) %c yfit = predict(t, puntos')'; count = 0; for i = 1:length(targetsPuntos) if strcmp(yfit2(i), targetsPuntos(i)) count = count+1; end end right = 100.0*count/length(targetsPuntos) %d t2 = fitctree(puntos(:, 1:300)', targetsPuntos(1:300)'); yfit2 = predict(t2, puntos(:, 301:400)')'; count2 = 0; for i = 1:length(targetsPuntos(301:400)) if strcmp(yfit2(i), targetsPuntos(300+i)) count2 = count2+1; end end right2 = 100.0*count2/length(targetsPuntos(301:400)) %f y = zeros(1,100); for m = 1:100 y(m) = yfit2(m) - double('0'); end gscatter(puntos(1,301:400), puntos(2,301:400), yfit2) % Ej 7 - Principio puntos3D = vertcat(puntos, 10 * rand(1, 400) - 5); targetsPuntos3D = targetsPuntos; N = length(puntos3D); % 400 for i = 1:N if puntos3D(3,i) < 0, targetsPuntos3D(1, i) = targetsPuntos(1, i) + 4; end end scatter3(puntos3D(1,:), puntos3D(2,:), puntos3D(3,:), 10*ones(1,N), targetsPuntos3D)