Crossval for classification error

9 views (last 30 days)
Alberto Azzari
Alberto Azzari on 3 Apr 2020
Hi, I'm trying to classify a dataset using lasso (not the built-in one function), I'm using a crossvalidation. The error I get is this:
Error using crossval> evalFun (line 488)
The function 'lasso_pred' generated the following error:
Undefined function 'minus' for input arguments of type 'nominal'.
Error in crossval> getLossVal (line 525)
funResult = evalFun (funorStr, arg (1: end-1));
Error in crossval (line 424)
                 [funResult, outarg] = getLossVal (i, nData, cvp, data, predfun);
Error in test (line 59)
cv_error_lasso = crossval ('mcr', X, y, 'Predfun', @lasso_pred, 'Partition', cvp_lasso);
Below I put the code:
cvp_lasso = cvpartition(y, 'LeaveOut');
cv_error_lasso = crossval('mcr', X, y, 'Predfun', @lasso_pred, 'Partition', cvp_lasso);
This is the funct:
function yfit = lasso_pred(Xtrain, ytrain, Xtest)
B = lasso(Xtrain, ytrain);
yfit = Xtest * B(:, end);
end
Thanks!

Answers (1)

Harsha Priya Daggubati
Harsha Priya Daggubati on 6 Apr 2020

Community Treasure Hunt

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

Start Hunting!