Using Cross Validation for regression
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Ahmet Cecen
il 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
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!