resubMargin

Class: ClassificationEnsemble

Classification margins by resubstitution

Syntax

`margin = resubMargin(ens)margin = resubMargin(ens,Name,Value)`

Description

`margin = resubMargin(ens)` returns the classification margin obtained by `ens` on its training data.

`margin = resubMargin(ens,Name,Value)` calculates margins with additional options specified by one or more `Name,Value` pair arguments.

Input Arguments

 `ens` A classification ensemble created with `fitensemble`.

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`.

 `'learners'` Indices of weak learners in the ensemble ranging from `1` to `NumTrained`. `resubMargin` uses only these learners for calculating margin. Default: `1:NumTrained`

Output Arguments

 `margin` A numeric column-vector of length `size(ens.X,1)` containing the classification margins.

Definitions

Margin

The classification margin is the difference between the classification score for the true class and maximal classification score for the false classes. Margin is a column vector with the same number of rows as in the matrix `ens``.X`.

Score (ensemble)

For ensembles, a classification score represents the confidence of a classification into a class. The higher the score, the higher the confidence.

Different ensemble algorithms have different definitions for their scores. Furthermore, the range of scores depends on ensemble type. For example:

• `AdaBoostM1` scores range from –∞ to ∞.

• `Bag` scores range from `0` to `1`.

Examples

Find the resubstitution margins for an ensemble that classifies the Fisher iris data:

```load fisheriris ens = fitensemble(meas,species,'AdaBoostM2',100,'Tree'); margin = resubMargin(ens); [min(margin) mean(margin) max(margin)] ans = -0.5674 3.2486 4.6245```