how to predict response using test data after using 'KFold ', 5 in case of SVM

Hi there...after training a model using following code Mdl = fitrsvm(predictortrain,response,'standardize', true, 'kFold', 5) now kindly tell me how can i calculate the response using 'Kfoldpredict' instead of predict and which parameter i have to pass for 'Kfoldpredict'. as i have seperate data for testing kindly let me know if you have any solution.

2 Kommentare

if you want to use the 'Kfoldpredict' you need to do some step before, i will post an example.
kindly post your example please.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

once you trained the model. now you want to use 'Kfoldpredict', first you validate your model. e.g;
Mdl = fitcecoc(features_train,labels_train,'Learners',t,'FitPosterior',1,...
'ClassNames',{'1','2','3','4','5','6','7'},...
'Verbose',2);
CVMdl = crossval(Mdl); % cross- validate Mdl
oosLoss = kfoldLoss(CVMdl);
label = predict(Mdl,features_test); % if want to predict
oofLabel = kfoldPredict(CVMdl);
i hope itwill help you.

7 Kommentare

oky thank you. let me implement this code
sir when i run this code CVMdl = crossval(Mdl); getting this error Error using crossval (line 160) At least two inputs are needed. now wht i have to do?
Mdl = fitrsvm(predictortrain,response,'standardize', true, 'kFold', 5) CVMdl = crossval(Mdl); getting error like this "Error using crossval (line 160) At least two inputs are needed"
sir come across a point that if in this command
Mdl = fitrsvm(predictortrain,response,'standardize', true,) then using
CVMdl = crossval(Mdl)
by eliminating KFoLd 5 then not getting this error.
if i want to use kFold 5 then how this code will work. because using
CVMdl = crossval(Mdl);
this code default Kfold = 10,
that i don't want to use.
Saba, I am facing the same problem. Did you find the solution to your problem? Can you please share it?
You are not setting the right number of parameters;
Try this, will get right output with 5-fold
Mdl = fitrsvm(predictortrain,response,'standardize', true);
CVMdl = crossval(Mdl, 'kfold', 5);

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 27 Sep. 2018

Beantwortet:

am 24 Jul. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by