Using Cross Validation for regression
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Ahmet Cecen
el 14 de Abr. de 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
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!