FUNCTION REFERENCE

loss

Compute validation loss for classification or regression models.

Compute validation loss for classification or regression models.

Syntax

L = loss(mdl,X,Y,'LossFun','classiferror')

Regression learners support unweighted MSE (default or LossFun='mse'), omitting missing numeric test rows. Classification losses are available for every classifier. LossFun supports classiferror (default), mincost with the default zero-one cost matrix, binodeviance, exponential and hinge. The latter losses use signed positive-class score for binary problems and true-class score for multiclass problems, following the public classification loss formulas. Table predictors are selected by model predictor names.

Example

m=fitcknn([0;2],[1;2]); loss(m,[0;2],[1;2])

Example

m=fitrlinear([0;1;2],[1;2;4],'Lambda',0.1); loss(m,[0;2],[1;4])

Differences from MATLAB: Only the built-in zero-one cost matrix is supported. Observations are weighted by the model class priors; custom observation weights are unsupported.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.