フィルターのクリア

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 Center および File ExchangeGaussian Process Regression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by