K-fold Cross Validation Performance
Show older comments
Hello All, I am a newbie in Validating models, I am currently trying to make use of the MATLAB K-fold validation to assess the performance of my polynomial model that predicts house prices. I have 243 samples, i divided them into 10 groups, i then used 'for loop' to test 9 groups against 1 group (repeated X 10) My problem is storing the error rate (performance) for the 10 times i am making the prediction. How do i do that please? I tried making use of 'classperf' but i am getting the following error, Please see my code below;
Data set sample:
DateX: 10,20,30,40 ... PriceY: 200,250,300,400 ...
--------Code (MATLAB)-------
K = 10;
cvFolds = crossvalind('Kfold',DateX,K); %10-folds
cp = classperf(DateX); %To store (performance)
for i = 1:K
testIDx = (cvFolds == i);
trainIDx = ~testIDx;
model1 = polyfit(DateX(trainIDx),PriceY(trainIDx),2);
prediction1=model1(1)*DateX(testIDx).^2+model1(2)*DateX(testIDx)+model1(3);
cp = classperf(cp,prediction1,testIDx);
end
My Error Message;
Error using classperf (line 230) When the class labels of the CP object are numeric, the output of the classifier must be all non-negative integers or NaN's.
Is there any suggestions please on how i can store the performance of my model AND i would apperciate examples of other methods In MATLAB that i can apply to make predictions and validate performance (Neural networks, Classification e.t.c.)?? THANK YOU!
Accepted Answer
More Answers (0)
Categories
Find more on Expression Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!