K-fold Cross Validation Performance

2 ビュー (過去 30 日間)
Ahmad
Ahmad 2014 年 12 月 3 日
回答済み: Greg Heath 2014 年 12 月 12 日
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!

採用された回答

Greg Heath
Greg Heath 2014 年 12 月 12 日
I do not have the functions crossvalind and classperf.
Although I do have crossval and cvpartition, I favor my own code used in the following NEWSGROUP posts:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/326830#898048
http://www.mathworks.com/matlabcentral/newsreader/view_thread/331830#911882
Hope this helps.
Thank you for formally accepting my answer
Greg

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGaussian Process Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by