Documentation |
L = resubLoss(ens)
L = resubLoss(ens,Name,Value)
L = resubLoss(ens) returns the resubstitution loss, meaning the mean squared error computed for the data that fitensemble used to create ens.
L = resubLoss(ens,Name,Value) calculates 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.
ens |
A regression ensemble created with fitensemble. |
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.
'learners' |
Indices of weak learners in the ensemble ranging from 1 to NumTrained. resubLoss uses only these learners for calculating loss. Default: 1:NumTrained |
'lossfun' |
Function handle for loss function, or the string 'mse', meaning mean squared error. If you pass a function handle fun, resubLoss 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, and W is the observation weights. Default: 'mse' |
'mode' |
String representing the meaning of the output L:
Default: 'ensemble' |
L |
Loss, by default the mean squared error. L can be a vector, and can mean different things, depending on the name-value pair settings. |
Find the resubstitution predictions of mileage from the carsmall data based on horsepower and weight, and look at their mean square difference from the training data.
load carsmall X = [Horsepower Weight]; ens = fitensemble(X,MPG,'LSBoost',100,'Tree'); MSE = resubLoss(ens) MSE = 6.4336