How to save a test set and still cross validate data using the cross validation functions?

I've been trying to figure this out for a few days.
Basically, I want to save a test set and not touch it while cross validating my model. Then after my model is cross validated, I would like to run it on the test set. So far, I've been using the built in functions fitcsvm, crossvalind, and crossval. The problem I'm running into is that once I create a cross validated function with crossval, I can't seem to apply it to my saved test set. Instead, the crossval functions only seem to use only the validation data embedded within.
In summary, what I have done is:
1) use "crossvalind" to create indices for training (i.e. cross validation) and testing 2) use "fitcsvm" with training set to create an SVM classifier struct 3) use "crossval" function to cross validate the SVM struct to create a cross validated struct
What I want to do but cannot do is: 4) use the cross validated SVM struct on the test set to create predictions.
I am unable to use the "predict" function which appears to only work for the non-crossvalidated SVM. When I use the "kfoldpredict" function for the cross-validated SVM struct, it appears to only apply it to the training data to give a performance measure.
Any tips would be much appreciated!
Thanks, John

Answers (0)

Asked:

on 5 Nov 2016

Commented:

on 22 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!