Using Cross Validation for regression

5 Ansichten (letzte 30 Tage)
Can Lo
Can Lo am 13 Apr. 2016
Kommentiert: Can Lo am 14 Apr. 2016
hello, i have a dataset which has inputs 5x100 real numbers called "input" and i have 1x100 real numbers target called"output", and i need to use 10 fold crossvalidation but i m new in matlab and my dataset is not classification , it is for regression, and i cant use command " crossvalind=('Kfold',groups,k) because i dont have any groups,what should i do ? i have 100 samples and i have to use 90 of them for train,other 10 for test and i have to do this for 10 time for all datas and all datas must be used.

Antworten (1)

Ahmet Cecen
Ahmet Cecen am 14 Apr. 2016
I would do something along the lines of:
Randomize = randperm(length(input));
inputRandom = input(Randomize);
outputRandom = output(Randomize);
for i=1:10
Xtest = inputRandom(((i-1)*10+1):i*10);
ytest = outputRandom(((i-1)*10+1):i*10);
Xtrain = inputRandom; Xtrain(((i-1)*10+1):i*10) = [];
ytrain = outputRandom; ytrain(((i-1)*10+1):i*10) = [];
[b,bint,r,rint,stats] = regress(ytrain,Xtrain);
YCrossValidated = Xtest*b;
crossValidateResiduals = YCrossValidated - Ytest;
% Calculate any fit statistics HERE and STORE anything you need.
end
  1 Kommentar
Can Lo
Can Lo am 14 Apr. 2016
thank you so much for your help sir, i really appreciate it ! i didnt use this exactly but it gave me the idea :) but how can i use 10 fold crossvalidation for my situation ? or cross validation is only used for classification problems ?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by