Hi, does anyone knows if there is a function to crossvalidated my linear model? i can only find it for descision trees unfortunately.. Thank you!

 採用された回答

Greg Heath
Greg Heath 2014 年 8 月 9 日

1 投票

help crossval, doc crossval
help cvpartition, doc cvpartition
Hope this helps
Thank you for formally accepting my answer
Greg

2 件のコメント

Tania
Tania 2014 年 8 月 10 日
Thank you, do you know if this works although on more than 1 variable? would like to split my multiple linear model...
It looks like it does it only for one variable...
load fisheriris; y = species; c = cvpartition(y,'k',10);
Thank you!
Greg Heath
Greg Heath 2014 年 9 月 2 日
y is 3-dimensional
help iris

サインインしてコメントする。

その他の回答 (1 件)

Ahmet Cecen
Ahmet Cecen 2014 年 8 月 9 日
編集済み: Ahmet Cecen 2014 年 8 月 9 日

1 投票

This depends on how you would like to do the cross validation. Leave-one-out cross validation has a nice trick for linear models that can be exploited to perform the whole thing in mere seconds. If you would like to leave more out, or use a k-fold validation, you just have to retrain the model each time and calculate the cross-validation error. I am not aware of any native functions in MATLAB that does CV for linear models. My file exchange function MultiPolyRegressV3 has built in leave-one-out cross validation with the trick exploited.

カテゴリ

タグ

質問済み:

2014 年 8 月 9 日

コメント済み:

2014 年 9 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by