The question is regarding the Matlab implementation. As we can see here, the crossval function expects to receive a full trained model. For example, my data consist of 100 observations and we would like to build a model that classify each observation to "1" or "-1" using the SVM classifier. So if we like to cross validate we first should fit a classifier for all 100 observations (this results a ClassificationSVM model trained using fitcsvm) and then we input the crossval function with it.

What I don't understand is, why Matlab's implementation require to first train the model before cross validating? since the standard CV process trains on each k − 1 subsamples (and don't use the full fitted model).


1 Answer 1


If you have a model that is already trained on the full data, it is a ClassificationSVM object. There is a crossval method that you can use to perform cross-validation on it to assess its generalization error.

If you haven't trained a model yet and you want to do cross validation up front, you can use the 'CrossVal' option to the fitcsvm function, and set its value to 'on'.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.