Crossval for classification error
Show older comments
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
on 6 Apr 2020
0 votes
Hi,
Similar question is asked in the following thread:
Categories
Find more on Resampling Techniques in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!