Main Content

kfoldEdge

Classification edge for observations not used for training

Syntax

E = kfoldEdge(obj)
E = kfoldEdge(obj,Name,Value)

Description

E = kfoldEdge(obj) returns classification edge (average classification margin) obtained by cross-validated classification ensemble obj. For every fold, this method computes classification edge for in-fold observations using an ensemble trained on out-of-fold observations.

E = kfoldEdge(obj,Name,Value) calculates edge with additional options specified by one or more Name,Value pair arguments. You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

Input Arguments

ens

Object of class ClassificationPartitionedEnsemble. Create ens with fitcensemble along with one of the cross-validation options: 'crossval', 'kfold', 'holdout', 'leaveout', or 'cvpartition'. Alternatively, create ens from a classification ensemble with crossval.

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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'folds'

Indices of folds ranging from 1 to ens.KFold. Use only these folds for predictions.

Default: 1:ens.KFold

'mode'

Character vector or string scalar representing the meaning of the output edge:

  • 'average'edge is a scalar value, the average over all folds.

  • 'individual'edge is a vector of length ens.KFold with one element per fold.

  • 'cumulative'edge is a vector of length min(ens.NTrainedPerFold) in which element J is obtained by averaging values across all folds for weak learners 1:J in each fold.

Default: 'average'

Output Arguments

E

The average classification margin. E is a scalar or vector, depending on the setting of the mode name-value pair.

Examples

expand all

Compute the k-fold edge for an ensemble trained on the Fisher iris data.

Load the sample data set.

load fisheriris

Train an ensemble of 100 boosted classification trees.

t = templateTree('MaxNumSplits',1); % Weak learner template tree object
ens = fitcensemble(meas,species,'Learners',t);

Create a cross-validated ensemble from ens and find the classification edge.

rng(10,'twister') % For reproducibility
cvens = crossval(ens);
E = kfoldEdge(cvens)
E = 3.2033

More About

expand all