2
votes

I am trying to classify my input features into two classes using SVM. I want to use 10-fold cross-validation to train an SVM classifier. I am using MATLAB inbuilt functions. But while using predict() function along with crossval() function, I am getting an error:

No valid system or dataset was specified.

Does anyone knows how to resolve this issue?

Training_Features   = X;
Training_Labels     = Y;
SVMModel           = 
fitcsvm(Training_Features,Training_Labels,'KernelFunction','RBF');       
CVSVMModel          = crossval(SVMModel);

[Predict_Labels,Predict_Scores]     = 
predict(CVSVMModel,Training_Features);
1

1 Answers

1
votes

I think you understood the cross validation functionality wrong. Your CVSVMModel is a so called ClassificationPartitionedModel which has no function predict() since Cross Validation is meant for testing the generalisation of your model BEFORE you train it with the WHOLE dataset (not cross-validated).

I suggest the following:

  1. Call [Predict_Labels,Predict_Scores] = kfoldPredict(CVSVMModel); to see how well it does on each validation dataset during the cross-validation
  2. If you're satisfied train a new SVMModel with the whole dataset and predict with that one.

EDIT: A ClassificationPartitionedModel is a collection of models (in your case 10 different ones). You can access and even call predict() on them by for example:

[Predict_Labels,Predict_Scores] = predict(CVSVMModel.Trained{1, 1},X);