i 'm trying to use the minst data with the support vector machine (SVM) i have a problem with the time of execution because minist data have a large dimension 70k,how can i use the PCA to reduce these dimensions . test_set=[60 000*748];train_set=[10 000*748];train_label=[60 000*1] and test_label=[10 000*1] . thank you

clear all; load('train_set.mat') load('test_set.mat') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ù train_label=[0*ones(1,6000) 1*ones(1,6000) 2*ones(1,6000) 3*ones(1,6000) 4*ones(1,6000) 5*ones(1,6000) 6*ones(1,6000) 7*ones(1,6000) 8*ones(1,6000) 9*ones(1,6000)]; train_label1=train_label'; model = svmtrain(train_label1, train_set, '-s 0 -t 0'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% test_set=[0*ones(1,1000) 1*ones(1,1000) 2*ones(1,1000) 3*ones(1,1000) 4*ones(1,1000) 5*ones(1,1000) 6*ones(1,1000) 7*ones(1,1000) 8*ones(1,1000) 9*ones(1,1000) ]; test_set1=test_set'; [predicted_label, accuracy, decision_values]=svmpredict(test_label1, test_set, model); %%%%%%%%%%%% nt=1000; m=6000; [Pa,V,me1,l1] = pcaproj(train_set1,2); [n,p]=size(test_set1); Pt=(test_set1-ones(n,1)*me1)*V; min(Pa); max(Pa); min(Pt); max(Pt); m1 = -1; M1 = 2.5; m2 = -1.5; M2 = 1; ind1 = 0.25; ind2 = 0.25; [xg yg] = meshgrid([m1:ind1:M1],[m2:ind2:M2]); [nx,ny] = size(xg); X = [reshape(xg ,nx*ny,1) reshape(yg ,nx*ny,1)]; [n,p] = size(X); Xg = X*V' + ones(n,1)*me1; LabelS1=[1*ones(1,1000) 2*ones(1,1000) 3*ones(1,1000) 4*ones(1,1000) 5*ones(1,1000) 6*ones(1,1000) 7*ones(1,1000) 8*ones(1,1000) 9*ones(1,1000) 10*ones(1,1000) ]; [ypred, accuracy1, decision_values1]=svmpredict(LabelS1, Xg, model); decision_values1=decision_values1'; maxi=max(decision_values1); ypred = reshape(ypred,nx,ny); contourf(xg,yg,ypred);shading flat;hold on; [cs,h]=contour(xg,yg,ypred,[1 2 3]); clabel(cs,h); style= ['^+*']; color= ['kkk']; hold on; nbclass=max(train_label); for i=0:nbclass-1 h=plot(Pt(i*nt+1:(i+1)*nt,1),Pt(i*nt+1:(i+1)*nt,2),[style(i+1) color(i+1)]);hold on; end;

Similar questions and discussions