Crossval for classification error

조회 수: 3 (최근 30일)
Alberto Azzari
Alberto Azzari 2020년 4월 3일
답변: Harsha Priya Daggubati 2020년 4월 6일
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!

답변 (1개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 4월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by