FUNCTION REFERENCE

oobLoss

Compute out-of-bag loss for bagged classification or regression trees.

Compute out-of-bag loss for bagged classification or regression trees.

Syntax

L = oobLoss(mdl,'LossFun','classiferror')

Aggregates scores only from trees whose bootstrap samples excluded an observation. Rows without any out-of-bag prediction are omitted.

Example

rng(1); m=fitcensemble([0;1;4;5],[1;1;2;2],'Method','Bag','NumLearningCycles',20); oobLoss(m)

Regression ensembles return cumulative MSE by default; Mode='ensemble' returns the final scalar. Rows without an out-of-bag prediction are omitted; regression loss is NaN if none exist.

Example

rng(2); m=fitrensemble((0:9)',(0:9)','Method','Bag','NumLearningCycles',5); oobLoss(m,'Mode','ensemble')

Differences from MATLAB: Only Bag ensembles are supported. Classification returns scalar average loss with built-in LossFun names; regression supports unweighted MSE.

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