edit-error in classifier

1 回表示 (過去 30 日間)
FIR
FIR 2012 年 4 月 12 日
I have a code
load('fisheriris');
y = species;
X = meas;
cp = cvpartition(y,'k',10); % Stratified cross-validation
classf = TreeBagger(10,meas,species,'oobpred','on');
cvMCR = crossval('mcr',X,y,'predfun',classf,'partition',cp)
i get error as
Undefined function 'func2str' for input arguments of type 'TreeBagger'.
Error in crossval>evalFun (line 465)
error(message('stats:crossval:FunError', func2str( fun ), ME.message));

採用された回答

Ilya
Ilya 2012 年 4 月 12 日
In particular, 2nd example for crossval here http://www.mathworks.com/help/toolbox/stats/crossval.html shows what you need to do. You would need to replace the function handle classf in that example with a function which has two lines of code in it: 1) Train a TreeBagger on Xtrain and Ytrain, and 2) Predict labels for Xtest using the trained TreeBagger.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 4 月 12 日
The 'predfun' parameter expects a function handle as the associated value. Instead you passed in a TreeBagger object.
  1 件のコメント
FIR
FIR 2012 年 4 月 12 日
walter can u please tell what to pass

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

カテゴリ

Help Center および File ExchangeClassification Ensembles についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by