svmclassify

Classify data using a support vector machine

Syntax

Group = svmclassify(SVMStruct, Sample, 'PropertyName', PropertyValue...)
svmclassify(..., 'Showplot', ShowplotValue)

Description

Group = svmclassify(SVMStruct, Sample, 'PropertyName', PropertyValue...) classifies each row of the data in Sample using the information in a support vector machine classifier structure SVMStruct, created using svmtrain. 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.

svmclassify(..., 'Showplot', ShowplotValue) when Showplot is true, plots thesample data on the figure created using the showplot option in svmtrain.

Example

% Load the data and select features for classification
load fisheriris
data = [meas(:,1), meas(:,2)];
% Extract the Setosa class
groups = ismember(species,'setosa');
% Randomly select training and test sets 
[train, test] = crossvalind('holdOut',groups);
cp = classperf(groups);
% Use a linear support vector machine classifier
svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);
classes = svmclassify(svmStruct,data(test,:),'showplot',true);
% See how well the classifier performed
classperf(cp,classes,test);
cp.CorrectRate

This displays the following plot:

See Also

Statistical Toolbox functions classify, knnclassify, quadprog, svmtrain


© 1994-2005 The MathWorks, Inc.