error for crossval function
2 views (last 30 days)
Show older comments
Hi
I get an error for the following code:
esti = @(x,y)(lasso(x,y))
>> A = crossval(esti,training(:,end-1),training(:,end))
Error using crossval>evalFun (line 480) The function '@(x,y)(lasso(x,y))' generated the following error: Too many input arguments.
Error in crossval>getFuncVal (line 497) funResult = evalFun(funorStr,arg(:));
Error in crossval (line 343) funResult = getFuncVal(1, nData, cvp, data, funorStr, []);
why is that? feval works for the same arguments
2 Comments
Geoff Hayes
on 22 Oct 2014
The error message is telling you that too many (more than two) input parameters are being passed to the esti function (which only allows for two inputs). Looking at the documentation for crossval, if the call is
vals = crossval(fun,X)
then fun is a function handle to a function with two inputs. The final example indicates that if the function call is
cfMat = crossval(f,X,y,...)
which is similar to yours, then the f must be a handle to a function that takes four inputs - the first two being the training subsets for X and Y, and the latter two for the test subsets of X and Y.
You will have to adjust your call to crossval to do something similar. What are you hoping to achieve by passing the two training inputs with the lasso function?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!