Prev: Data Exchange Between Matlab and Third Party Software likeMetatrader 4
Next: Help estimating parameters to fit an ODE model to experimental data.
From: Tom on 22 Jun 2010 08:17 Hi, I am following the example on how to use crossval with decision trees: http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/classdemo.html I follow the code examples, but when I execute: dtclass = t.eval(meas(:,1:2)); bad = ~strcmp(dtclass,species); dtResubErr = sum(bad) / N dtClassFun = @(xtrain,ytrain,xtest)(eval(classregtree(xtrain,ytrain),xtest)) ; dtCVErr = crossval('mcr',meas(:,1:2),species, ... 'predfun', dtClassFun,'partition',cp) I get a Function Handle Error ??? Error using ==> crossval at 102 FUN must be a function handle. I have tried various ways around, but no luck. - Any suggestions. Regards, Tom
From: Alan Weiss on 22 Jun 2010 08:34 I just tried running this, and had no problems. Try executing echodemo classdemo See if you get through the demo OK. If not, try restarting MATLAB and then running the echodemo again. Alan Weiss MATLAB mathematical toolbox documentation On 6/22/2010 8:17 AM, Tom wrote: > Hi, > > I am following the example on how to use crossval with decision trees: > > http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/classdemo.html > > > I follow the code examples, but when I execute: > > dtclass = t.eval(meas(:,1:2)); > bad = ~strcmp(dtclass,species); > dtResubErr = sum(bad) / N > > dtClassFun = > @(xtrain,ytrain,xtest)(eval(classregtree(xtrain,ytrain),xtest)) > ; > dtCVErr = crossval('mcr',meas(:,1:2),species, ... > 'predfun', dtClassFun,'partition',cp) > > I get a Function Handle Error > > ??? Error using ==> crossval at 102 > FUN must be a function handle. > > I have tried various ways around, but no luck. - Any suggestions. > > Regards, > Tom
From: Ilya Narsky on 22 Jun 2010 09:51
Alan Weiss wrote: > I just tried running this, and had no problems. Try executing > echodemo classdemo > See if you get through the demo OK. If not, try restarting MATLAB and > then running the echodemo again. > > Alan Weiss > MATLAB mathematical toolbox documentation > > On 6/22/2010 8:17 AM, Tom wrote: >> Hi, >> >> I am following the example on how to use crossval with decision trees: >> >> http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/classdemo.html >> >> >> >> I follow the code examples, but when I execute: >> >> dtclass = t.eval(meas(:,1:2)); >> bad = ~strcmp(dtclass,species); >> dtResubErr = sum(bad) / N >> >> dtClassFun = >> @(xtrain,ytrain,xtest)(eval(classregtree(xtrain,ytrain),xtest)) >> ; >> dtCVErr = crossval('mcr',meas(:,1:2),species, ... >> 'predfun', dtClassFun,'partition',cp) >> >> I get a Function Handle Error >> >> ??? Error using ==> crossval at 102 >> FUN must be a function handle. >> >> I have tried various ways around, but no luck. - Any suggestions. >> >> Regards, >> Tom > In addition to what Alan said, I'd like to point out that classregtree has a built-in method for cross-validation. Do 'help classregtree/test'. Your choice however is limited to 10-fold cross-validation. -Ilya |