Shuffling training labels in cvpartition but testing on correct labels

4 views (last 30 days)
Apologies if this question has been asked before, but I could not find the relevant information in help docs or in the Answers forum so far.
Here is the issue:
I am performing an SVM binary classification on a table dataset, with 1 label column and 34 feature columns. I am utilizing cvpartition with kfold cross validation, pseudo-code as follows:
data %data table
nr_folds = 10
%creating partitions
partitions = cvpartition(data.labels,'KFold',nr_folds);
%model training
mdl = fitcsvm(data,'labels','CVpartition',partitions);
%model loss evaluation
model_loss = kfoldLoss(mdl,'Mode','individual');
Now I would like to run some controls, by randomly shuffling the data labels and check if my loss predictably increases. My understanding is that I should do the shuffling for the training set labels on each partition, while evaluating loss for the test set with correct labels. How can I shuffle the labels in the training set without altering the labels on the test set for each partition, with the general implementation in the above pseudocode? Thanks in advance for any clarification on this.

Answers (0)

Community Treasure Hunt

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

Start Hunting!