`mar = meanMargin(B,TBLnew,Ynew)`

mar = meanMargin(B,Xnew,Ynew)

mar = meanMargin(B,TBLnew,Ynew,'param1',val1,'param2',val2,...)

mar
= meanMargin(B,Xnew,Ynew,'param1',val1,'param2',val2,...)

`mar = meanMargin(B,TBLnew,Ynew)`

computes
average classification margins for the predictors contained in the
table `TBLnew`

given the true response `Ynew`

.
You can omit `Ynew`

if `TBLnew`

contains
the response variable. If you trained `B`

using sample
data contained in a table, then the input data for this method must
also be in a table.

`mar = meanMargin(B,Xnew,Ynew)`

computes
average classification margins for the predictors contained in the
matrix `Xnew`

given true response `Ynew`

.
If you trained `B`

using sample data contained in
a matrix, then the input data for this method must also be in a matrix.

`Ynew`

can be either a numeric vector, character
matrix, cell array of strings, categorical vector or logical vector. `meanMargin`

averages
the margins over all observations (rows) in `TBLnew`

or `Xnew`

for
each tree. `mar`

is a matrix of size 1-by-`NTrees`

,
where `NTrees`

is the number of trees in the ensemble `B`

.
This method is available for classification ensembles only.

`mar = meanMargin(B,TBLnew,Ynew,'param1',val1,'param2',val2,...)`

or ```
mar
= meanMargin(B,Xnew,Ynew,'param1',val1,'param2',val2,...)
```

specifies
optional parameter name-value pairs:

`'Mode'` | String indicating how `meanMargin` computes
errors. If set to `'cumulative'` (default), is a
vector of length NTrees where the first element gives mean margin
from `trees(1)` , second column gives mean margins
from `trees(1:2)` etc, up to `trees(1:NTrees)` .
If set to `'individual'` , `mar` is
a vector of length `NTrees` , where each element is
a mean margin from each tree in the ensemble . If set to `'ensemble'` , `mar` is
a scalar showing the cumulative mean margin 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
mean margin from `trees(1)` , the second element gives
mean margin from `trees(1:2)` etc. |

`'TreeWeights'` | Vector of tree weights. This vector must have the same length
as the `'Trees'` vector. `meanMargin` uses
these weights to combine output from the specified trees by taking
a weighted average instead of the simple nonweighted majority vote.
You cannot use this argument in the `'individual'` mode. |

Was this topic helpful?