svmcTrain2

Training SVM (support vector machine) classifier

Contents

Syntax

Description

svmModel=svmcTrain(DS) returns the parameters of SVM (support vector machine) based on the given dataset DS.

opt=svmcTrain('defaultOpt') returns the default options for SVM. You can modify the options if necessary, and send the options for training a SVM:

svmModel=svmcTrain(DS, opt)

Note that this function calls the mex files of libsvm directly. If the mex file svmtrain.mex* and svmpredict.mex* under [mltRoot, '/private'] is not found, you need to obtain it from libsvm website at "http://www.csie.ntu.edu.tw/~cjlin/libsvm/".

Example

DS=prData('iris');
DS.input=DS.input(3:4, :);
trainSet.input=DS.input(:, 1:2:end); trainSet.output=DS.output(:, 1:2:end);
testSet.input=DS.input(:, 2:2:end);  testSet.output=DS.output(:, 2:2:end);
[svmModel, logLike1, recogRate1]=svmcTrain(trainSet);
[computedClass, logLike2, recogRate2, hitIndex]=svmcEval(testSet, svmModel);
fprintf('Inside recog. rate = %g%%\n', recogRate1*100);
fprintf('Outside recog. rate = %g%%\n', recogRate2*100);
Error: can't read model: number of return field is not correct
Error using ==
Matrix dimensions must agree.

Error in classifierEval (line 215)
	hitIndex=find(computedClass==DS.output);

Error in classifierTrain (line 174)
		[computedClass, logLike, recogRate, hitIndex]=classifierEval(classifier, DS, cPrm);

Error in svmcTrain (line 38)
[cPrm, logLike, recogRate, hitIndex]=classifierTrain(classifier, DS, opt, showPlot);

Error in svmcTrain2_help (line 21)
[svmModel, logLike1, recogRate1]=svmcTrain(trainSet);

See Also

svmcEval.


Top page   Next: svmcTrain.m   Prev:taylorExpansionDemo.m