Using Cross Validation for regression
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
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
Siehe auch
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!