Error (misclassification probability or MSE)
Syntax
err = error(B,X,Y)
err = error(B,X,Y,'param1',val1,'param2',val2,...)
Description
err = error(B,X,Y) computes the misclassification
probability (for classification trees) or mean squared error (MSE,
for regression trees) for each tree, for predictors X given
true response Y. For classification, Y can
be either a numeric vector, character matrix, cell array of strings,
categorical vector or logical vector. For regression, Y must
be a numeric vector. err is a vector with one
error measure for each of the NTrees trees in the
ensemble B.
err = error(B,X,Y,'param1',val1,'param2',val2,...) specifies
optional parameter name/value pairs:
| 'mode' | String indicating how the method computes errors. If set to 'cumulative' (default), error computes
cumulative errors and err is a vector of length NTrees,
where the first element gives error from trees(1),
second element gives error fromtrees(1:2) etc,
up to trees(1:NTrees). If set to 'individual', err is
a vector of length NTrees, where each element is
an error from each tree in the ensemble. If set to 'ensemble', err is
a scalar showing the cumulative error for the entire ensemble. |
| 'trees' | Vector of indices indicating what trees to include in this
calculation. By default, this argument is set to 'all' and
the method uses all trees. If 'trees' is a numeric
vector, the method returns a vector of length NTrees for 'cumulative' and 'individual' modes,
where NTrees is the number of elements in the input
vector, and a scalar for 'ensemble' mode. For example,
in the 'cumulative' mode, the first element gives
error from trees(1), the second element gives error
from trees(1:2) etc. |
| 'treeweights' | Vector of tree weights. This vector must have the same length
as the 'trees' vector. The method uses these weights
to combine output from the specified trees by taking a weighted average
instead of the simple non-weighted majority vote. You cannot use this
argument in the 'individual' mode. |
| 'useifort' | Logical matrix of size Nobs-by-NTrees indicating
which trees should be used to make predictions for each observation.
By default the method uses all trees for all observations. |
See Also
TreeBagger.error
 | eq (qrandstream) | | error (TreeBagger) |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit