0
votes

I would like to draw learning curves for a given SVM classifier. Thus, in order to do this, I would like to compute the training, cross-validation and test error, and then plot them while varying some parameter (e.g., number of instances m).

How to compute training, cross-validation and test error on libsvm when used with MATLAB?

I have seen other answers (see example) that suggest solutions for other languages.

Isn't there a compact way of doing it?

1

1 Answers

0
votes

Given a set of instances described by:

  • a set of features featureVector;
  • their corresponding labels (e.g., either 0 or 1),

if a model was previously inferred via libsvm, the MSE error can be computed as follows:

[predictedLabels, accuracy, ~] = svmpredict(labels, featureVectors, model,'-q');
MSE = accuracy(2);

Notice that predictedLabels contains the labels that were predicted by the classifier for the given instances.