matlab-problem number 2 please An interesting characteristic of soil is the perc
ID: 2249158 • Letter: M
Question
matlab-problem number 2 please
Explanation / Answer
function [iterfin] = multisvm( T,C,test ) %Inputs: T=Training Matrix, C=Group, test=Testing matrix %Outputs: iterfin=Resultant class iterind=size(test,1); iterfin=[]; Cb=C; Tb=T; for tempind=1:iterind tst=test(tempind,:); C=Cb; T=Tb; u=unique(C); N=length(u); c4=[]; c3=[]; j=1; k=1; if(N>2) itr=1; classes=0; cond=max(C)-min(C); while((classes~=1)&&(itr1 && cond>0) %This while loop is the multiclass SVM Trick c1=(C==u(itr)); newClass=c1; %svmStruct = svmtrain(T,newClass,'kernel_function','rbf'); % I am using rbf kernel function, you must change it also svmStruct = svmtrain(T,newClass); classes = svmclassify(svmStruct,tst); % This is the loop for Reduction of Training Set for i=1:size(newClass,2) if newClass(1,i)==0; c3(k,:)=T(i,:); k=k+1; end end T=c3; c3=[]; k=1; % This is the loop for reduction of group for i=1:size(newClass,2) if newClass(1,i)==0; c4(1,j)=C(1,i); j=j+1; end end C=c4; c4=[]; j=1; cond=max(C)-min(C); % Condition for avoiding group %to contain similar type of values %and the reduce them to process % This condition can select the particular value of iteration % base on classes if classes~=1 itr=itr+1; end end end valt=Cb==u(itr); % This logic is used to allow classification val=Cb(valt==1); % of multiple rows testing matrix val=unique(val); itrfin(tempind,:)=val; end endRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.