Main Content

resume

Resume training ensemble

Syntax

ens1 = resume(ens,nlearn)
ens1 = resume(ens,nlearn,Name,Value)

Description

ens1 = resume(ens,nlearn) trains ens for nlearn more cycles. resume uses the same training options fitcensemble used to create ens, except for parallel training options. If you want to resume training in parallel, pass the 'Options' name-value pair.

Note

You cannot resume training when ens is a Subspace ensemble created with 'AllPredictorCombinations' number of learners.

ens1 = resume(ens,nlearn,Name,Value) trains ens with additional options specified by one or more Name,Value pair arguments.

Input Arguments

ens

A classification ensemble, created with fitcensemble.

nlearn

A positive integer, the number of cycles for additional training of ens.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

NPrint

Printout frequency, a positive integer scalar or 'off' (no printouts). When NPrint is a positive integer, displays a message to the command line after training NPrint weak learners.

Tip

For fastest training of some boosted decision trees, set NPrint to the default value 'off'. This tip holds when the classification Method is 'AdaBoostM1', 'AdaBoostM2', 'GentleBoost', or 'LogitBoost', or when the regression Method is 'LSBoost'.

Default: 'off'

Options

Options for computing in parallel and setting random numbers, specified as a structure. Create the Options structure with statset.

Note

You need Parallel Computing Toolbox™ to compute in parallel.

You can use the same parallel options for resume as you used for the original training. However, you can change the parallel options as needed. This table lists the option fields and their values.

Field NameValueDefault
UseParallel

Set this value to true to compute in parallel. Parallel ensemble training requires you to set the 'Method' name-value argument to 'Bag'. Parallel training is available only for tree learners, the default type for 'Bag'.

false
UseSubstreams

Set this value to true to run computations in parallel in a reproducible manner.

To compute reproducibly, set Streams to a type that allows substreams: 'mlfg6331_64' or 'mrg32k3a'.

false
StreamsSpecify this value as a RandStream object or cell array of such objects. Use a single object except when the UseParallel value is true and the UseSubstreams value is false. In that case, use a cell array that has the same size as the parallel pool.If you do not specify Streams, then resume uses the default stream or streams.

For dual-core systems and above, resume parallelizes training using Intel® Threading Building Blocks (TBB). Therefore, specifying the UseParallel option as true might not provide a significant speedup on a single computer. For details on Intel TBB, see https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html.

Example: 'Options',statset('UseParallel',true)

Output Arguments

ens1

The classification ensemble ens, augmented with additional training.

Examples

expand all

Train a classification ensemble for three cycles, and compare the resubstitution error obtained after training the ensemble for more cycles.

Load the ionosphere data set.

load ionosphere

Train a classification ensemble for three cycles and examine the resubstitution error.

ens = fitcensemble(X,Y,'Method','GentleBoost','NumLearningCycles',3);
L = resubLoss(ens)
L = 0.0085

Train for three more cycles and examine the new resubstitution error.

ens1 = resume(ens,3);
L = resubLoss(ens1)
L = 0

The resubstitution error is much lower in the new ensemble than the original.

Extended Capabilities