필터 지우기
필터 지우기

error for crossval function

조회 수: 3 (최근 30일)
MiauMiau
MiauMiau 2014년 10월 22일
댓글: MiauMiau 2014년 10월 24일
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
Geoff Hayes
Geoff Hayes 2014년 10월 22일
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?
MiauMiau
MiauMiau 2014년 10월 24일
Well, I was doing the fitting with lasso function and wanted to perform then crossvalidation on my dataset. I understand now that I write a function which would take care of applying the fitting (lasso) to the data splited by crossval, so I wrote an anonymous function which I pass to the crossval, whereby the annonymous function now applies lasso to the splitted datasets and in my case returns the MSE. Thanks for your inputs!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by