Main Content


Class: TreeBagger

Train additional trees and add to ensemble


B = growTrees(B,ntrees)
B = growTrees(B,ntrees,'param1',val1,'param2',val2,...)


B = growTrees(B,ntrees) grows ntrees new trees and appends them to those trees already stored in the ensemble B.

B = growTrees(B,ntrees,'param1',val1,'param2',val2,...) specifies optional parameter name/value pairs:

'NumPrint'Specifies that a diagnostic message showing training progress should display after every value training cycles (grown trees). Default is no diagnostic messages.

A struct that specifies options that govern computation when growing the ensemble of decision trees. One option requests that the computation of decision trees on multiple bootstrap replicates uses multiple processors, if the Parallel Computing Toolbox™ is available. Two options specify the random number streams to use in selecting bootstrap replicates. You can create this argument with a call to statset. You can retrieve values of the individual fields with a call to statget. Applicable statset parameters are:

  • 'UseParallel' — If true and Parallel Computing Toolbox is installed, then the software uses an existing parallel pool for parallel trees, or, depending on parallel preferences, the software opens and uses a new pool if none is currently open. Otherwise, the software computes in serial. Default is false, meaning serial computation.

    For dual-core systems and above, TreeBagger parallelizes training using Intel® Threading Building Blocks (TBB). Therefore, using the 'UseParallel' option on a single computer may not speed up computation much and may consume more memory than in serial. For details on Intel TBB, see

  • UseSubstreams — Set to true to compute in parallel in a reproducible fashion. Default is false. To compute reproducibly, set Streams to a type allowing substreams: 'mlfg6331_64' or 'mrg32k3a'.

  • Streams — A RandStream object or cell array of such objects. If you do not specify Streams, growTrees uses the default stream or streams. If you choose to specify Streams, use a single object except in the case

    • UseParallel is true

    • UseSubstreams is false

    In that case, use a cell array the same size as the Parallel pool.

Extended Capabilities