Classification margins for observations not used for training


M = kfoldMargin(obj)


M = kfoldMargin(obj) returns classification margins obtained by cross-validated classification model obj. For every fold, this method computes classification margins for in-fold observations using a model trained on out-of-fold observations.

Input Arguments


A partitioned classification model of type ClassificationPartitionedModel or ClassificationPartitionedEnsemble.

Output Arguments


The classification margin.


expand all

Find the k-fold margins for an ensemble that classifies the ionosphere data.

Load the ionosphere data set.

load ionosphere

Create a template tree stump.

t = templateTree('MaxNumSplits',1);

Train a classification ensemble of decision trees. Specify t as the weak learner.

Mdl = fitcensemble(X,Y,'Method','AdaBoostM1','Learners',t);

Cross validate the classifier using 10-fold cross validation.

cvens = crossval(Mdl);

Compute the k-fold margins. Display summary statistics for the margins.

m = kfoldMargin(cvens);
marginStats = table(min(m),mean(m),max(m),...
marginStats=1×3 table
      Min       Mean      Max  
    _______    ______    ______

    -11.312    7.3236    23.517

More About

expand all