L = loss(ens,X,Y)
L = loss(ens,X,Y,Name,Value)
A matrix of predictor values. Each column of X represents one variable, and each row represents one observation.
NaN values in X are taken to be missing values. Observations with all missing values for X are not used in the calculation of loss.
A numeric column vector with the same number of rows as X. Each entry in Y is the response to the data in the corresponding row of X.
NaN values in Y are taken to be missing values. Observations with missing values for Y are not used in the calculation of loss.
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.
Indices of weak learners in the ensemble ranging from 1 to ens.NumTrained. oobEdge uses only these learners for calculating loss.
Function handle for loss function, or the string 'mse', meaning mean squared error. If you pass a function handle fun, loss calls it as
where Y, Yfit, and W are numeric vectors of the same length.
The returned value fun(Y,Yfit,W) should be a scalar.
String representing the meaning of the output L:
A logical matrix of size N-by-NumTrained, where N is the number of observations in ens.X, and NumTrained is the number of weak learners. When UseObsForLearner(I,J) is true, predict uses learner J in predicting observation I.
Weighted mean squared error of predictions. The formula for loss is in Weighted Mean Squared Error.
Let n be the number of rows of data, xj be the jth row of data, yj be the true response to xj, and let f(xj) be the response prediction of ens to xj. Let w be the vector of weights (all one by default).
First the weights are divided by their sum so they add to one: w→w/Σw. The mean squared error L is
Find the loss of an ensemble predictor of the carsmall data to find MPG as a function of engine displacement, horsepower, and vehicle weight:
load carsmall X = [Displacement Horsepower Weight]; ens = fitensemble(X,MPG,'LSBoost',100,'Tree'); L = loss(ens,X,MPG) L = 4.3904