kfoldLoss

Class: RegressionPartitionedEnsemble

Cross-validation loss of partitioned regression ensemble

Syntax

L = kfoldLoss(cvens)
L = kfoldLoss(cvens,Name,Value)

Description

L = kfoldLoss(cvens) returns the cross-validation loss of cvens.

L = kfoldLoss(cvens,Name,Value) returns cross-validation loss with additional options specified by one or more Name,Value pair arguments. You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

Input Arguments

cvens

Object of class RegressionPartitionedEnsemble. Create obj with fitensemble along with one of the cross-validation options: 'crossval', 'kfold', 'holdout', 'leaveout', or 'cvpartition'. Alternatively, create obj from a regression ensemble with crossval.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'folds'

Indices of folds ranging from 1 to cvens.KFold. Use only these folds for predictions.

Default: 1:cvens.KFold

'lossfun'

Function handle for loss function, or the string 'mse', meaning mean squared error. If you pass a function handle fun, loss calls it as

fun(Y,Yfit,W)

where Y, Yfit, and W are numeric vectors of the same length.

  • Y is the observed response.

  • Yfit is the predicted response.

  • W is the observation weights.

The returned value fun(Y,Yfit,W) should be a scalar.

Default: 'mse'

'mode'

String representing the meaning of the output L:

  • 'ensemble'L is a scalar value, the loss for the entire ensemble.

  • 'individual'L is a vector with one element per trained learner.

  • 'cumulative'L is a vector in which element J is obtained by using learners 1:J from the input list of learners.

Default: 'ensemble'

Output Arguments

L

The loss (mean squared error) between the observations in a fold when compared against predictions made with an ensemble trained on the out-of-fold data. L can be a vector, and can mean different things, depending on the name-value pair settings.

Examples

Find the cross-validation loss for a regression ensemble of the carsmall data:

load carsmall
X = [Displacement Horsepower Weight];
rens = fitensemble(X,MPG,'LSboost',100,'Tree');
cvrens = crossval(rens);
L = kfoldLoss(cvrens)

L =
   25.6935
Was this topic helpful?