Crossval for classification error
Afficher commentaires plus anciens
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!
Réponses (1)
Harsha Priya Daggubati
le 6 Avr 2020
0 votes
Hi,
Similar question is asked in the following thread:
Catégories
En savoir plus sur Resampling Techniques dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!