multi-class support vector machine classification -
i try run own svm-code using 1 against 1 have error in selected function best (c,sigma) , error in plot function ,i hope give me hand,and code
clear clc close %load data load dataset load spacies [~,~,group] = unique(spacies); data=dataset(1:12,1:19); xdata=zscore(data); %group=spacies(1:end,1); p=0.5; [train,test]=crossvalind('holdout',group,p); trainingsample=xdata(train,:); traininglabel=group(train,1); testingsample=xdata(test,:); testinglabel=group(test,1); numclass=max(group); i=1:numclass j=i+1:numclass inij=(traininglabel==i)|(traininglabel==j); trainingsampleij=trainingsample(inij,:); traininglabelij=traininglabel(inij,:); %%k-fold using training data numfold=8; indices=crossvalind('kfold',traininglabelij,numfold); sigma=2.^(-10:1:10); c=2.^(-5:1:5); [bestsigma,bestc]=bestparametersrbf(trainingsampleij,... traininglabelij,sigma,c,indices,numfold); %%performance svmstruct=svmtrain(trainingsampleij,traininglabelij,... 'showplot',true,'kernel_function','rbf','rbf_sigma',bestsigma,... 'boxconstraint',bestc); title(sprintf('kernel function: %s','rbf',... func2str(svmstruct.kernelfunction)),... 'interpreter','none'); classes=svmclassify(svmstruct,testingsample,'showplot',true); end end acc=mean(grp2idx(classes)==grp2idx(testinglabel));
training data data used train classifier (for example svm).
test data used test performance of trained classifier.
Comments
Post a Comment