| Bioinformatics Toolbox™ | ![]() |
Group = svmclassify(SVMStruct, Sample)
Group = svmclassify(SVMStruct, Sample, 'Showplot', ShowplotValue)
Group = svmclassify(SVMStruct, Sample) classifies each row of the data in Sample using the information in a support vector machine classifier structure SVMStruct, created using the svmtrain function. Sample must have the same number of columns as the data used to train the classifier in svmtrain. Group indicates the group to which each row of Sample has been assigned.
Group = svmclassify(SVMStruct, Sample, 'Showplot', ShowplotValue) controls
the plotting of the sample data in the figure created using the Showplot property
with the svmtrain function.
Load the sample data, which includes Fisher's iris data of 5 measurements on a sample of 150 irises.
load fisheriris
Create data, a two-column matrix containing sepal length and sepal width measurements for 150 irises.
data = [meas(:,1), meas(:,2)];
From the species vector, create a new column vector, groups, to classify data into two groups: Setosa and non-Setosa.
groups = ismember(species,'setosa');
Randomly select training and test sets.
[train, test] = crossvalind('holdOut',groups);
cp = classperf(groups);Use the svmtrain function to train an SVM classifier using a linear kernel function and plot the grouped data.
svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);

Add a title to the plot, using the KernelFunction field from the svmStruct structure as the title.
title(sprintf('Kernel Function: %s',...
func2str(svmStruct.KernelFunction)),...
'interpreter','none');

Classify the test set using a support vector machine.
classes = svmclassify(svmStruct,data(test,:),'showplot',true);

Evaluate the performance of the classifier.
classperf(cp,classes,test);
cp.CorrectRate
ans =
0.9867Use a one-norm, hard margin support vector machine classifier by changing the boxconstraint property.
figure
svmStruct = svmtrain(data(train,:),groups(train),...
'showplot',true,'boxconstraint',1e6);

classes = svmclassify(svmStruct,data(test,:),'showplot',true);

Evaluate the performance of the classifier.
classperf(cp,classes,test);
cp.CorrectRate
ans =
0.9867[1] Kecman, V., Learning and Soft Computing, MIT Press, Cambridge, MA. 2001.
[2] Suykens, J.A.K., Van Gestel, T., De Brabanter, J., De Moor, B., and Vandewalle, J., Least Squares Support Vector Machines, World Scientific, Singapore, 2002.
[3] Scholkopf, B., and Smola, A.J., Learning with Kernels, MIT Press, Cambridge, MA. 2002.
[4] Cristianini, N., and Shawe-Taylor, J. (2000). An Introduction to Support Vector Machines and Other Kernel-based Learning Methods, First Edition (Cambridge: Cambridge University Press). http://www.support-vector.net/
Bioinformatics Toolbox™ functions: classperf, crossvalind, knnclassify, svmtrain
Statistics Toolbox™ function: classify
Optimization Toolbox™ function: quadprog
![]() | sptread | svmsmoset | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |