Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create decision tree template

`t = templateTree`

`t = templateTree(Name,Value)`

returns
a default decision tree learner template suitable for training ensembles
or error-correcting output code (ECOC) multiclass models. Specify `t`

= templateTree`t`

as
a learner using:

`fitcensemble`

for classification ensembles`fitrensemble`

for regression ensembles`fitcecoc`

for ECOC model classification

If you specify a default decision tree template, then
the software uses default values for all input arguments during training.
It is good practice to specify the type of decision tree, e.g., for
a classification tree template, specify `'Type','classification'`

.
If you specify the type of decision tree and display `t`

in
the Command Window, then all options except `Type`

appear
empty (`[]`

).

creates
a template with additional options specified by one or more name-value
pair arguments.`t`

= templateTree(`Name,Value`

)

For example, you can specify the algorithm used to find the best split on a categorical predictor, the split criterion, or the number of predictors selected for each split.

If you display `t`

in the Command Window, then
all options appear empty (`[]`

), except those that
you specify using name-value pair arguments. During training, the
software uses default values for empty options.

To accommodate

`MaxNumSplits`

, the software splits all nodes in the current*layer*, and then counts the number of branch nodes. A layer is the set of nodes that are equidistant from the root node. If the number of branch nodes exceeds`MaxNumSplits`

, then the software follows this procedure.Determine how many branch nodes in the current layer need to be unsplit so that there would be at most

`MaxNumSplits`

branch nodes.Sort the branch nodes by their impurity gains.

Unsplit the desired number of least successful branches.

Return the decision tree grown so far.

This procedure aims at producing maximally balanced trees.

The software splits branch nodes layer by layer until at least one of these events occurs.

There are

`MaxNumSplits`

+ 1 branch nodes.A proposed split causes the number of observations in at least one branch node to be fewer than

`MinParentSize`

.A proposed split causes the number of observations in at least one leaf node to be fewer than

`MinLeafSize`

.The algorithm cannot find a good split within a layer (i.e., the pruning criterion (see

`PruneCriterion`

), does not improve for all proposed splits in a layer). A special case of this event is when all nodes are pure (i.e., all observations in the node have the same class).For values

`'curvature'`

or`'interaction-curvature'`

of`PredictorSelection`

, all tests yield*p*-values greater than 0.05.

`MaxNumSplits`

and`MinLeafSize`

do not affect splitting at their default values. Therefore, if you set`'MaxNumSplits'`

, then splitting might stop due to the value of`MinParentSize`

before`MaxNumSplits`

splits occur.For details on selecting split predictors and node-splitting algorithms when growing decision trees, see Algorithms for classification trees and Algorithms for regression trees.

[1] Breiman, L., J. Friedman, R. Olshen, and
C. Stone. *Classification and Regression Trees*.
Boca Raton, FL: CRC Press, 1984.

[2] Coppersmith, D., S. J. Hong, and J. R.
M. Hosking. “Partitioning Nominal Attributes in Decision Trees.” *Data
Mining and Knowledge Discovery*, Vol. 3, 1999, pp. 197–217.

[3] Loh, W.Y. “Regression Trees with
Unbiased Variable Selection and Interaction Detection.” *Statistica
Sinica*, Vol. 12, 2002, pp. 361–386.

[4] Loh, W.Y. and Y.S. Shih. “Split
Selection Methods for Classification Trees.” *Statistica
Sinica*, Vol. 7, 1997, pp. 815–840.

`ClassificationTree`

| `RegressionTree`

| `fitcecoc`

| `fitcensemble`

| `fitctree`

| `fitrensemble`

Was this topic helpful?