MATLAB Answers

Should I use cvpartition before using crossval function?

3 views (last 30 days)
Umit Kilic
Umit Kilic on 18 Jan 2021
Commented: Umit Kilic on 18 Jan 2021
Hi friends,
I am trying to use k-fold cross validation in Matlab. I analyze the examples and Matlab documents about it but I am confused at one point. Can you tell me which usage is correct ?
Usage 1:
%feat is x data of all data set label is y data of all data set.
Usage 2:
SVMModel = fitcecoc(trainingData,classes);
cp = cvpartition(classes, 'k', 10);
CVM = crossval(SVMModel, 'CVPartition', cp);
Also, does the usage of this line of code change according to the classifier used in the code? For example, if I use fitcsvm instead of fitcknn, should I remove any function? (I think, I should not.)
  1 Comment
Umit Kilic
Umit Kilic on 18 Jan 2021
Cross-validation partition, specified as the comma-separated pair consisting of 'CVPartition' and a cvpartition object created by the cvpartition function. crossval splits the data into subsets with cvpartition.
I see the above information from crossval documentation. I think first usage is enough, because the info says that crossval uses cvpartitionn function already. Even so, I would like to hear your response.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by