Input Arguments

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.

Pruning level, specified as the comma-separated pair consisting
of 'Subtrees' and a vector of nonnegative integers
in ascending order or 'all'.

If you specify a vector, then all elements must be at least 0 and
at most max(tree.PruneList). 0 indicates
the full, unpruned tree and max(tree.PruneList) indicates
the completely pruned tree (i.e., just the root node).

If you specify 'all', then resubPredict operates
on all subtrees (i.e., the entire pruning sequence). This specification
is equivalent to using 0:max(tree.PruneList).

resubPredict prunes tree to
each level indicated in Subtrees, and then estimates
the corresponding output arguments. The size of Subtrees determines
the size of some output arguments.

To invoke Subtrees, the properties PruneList and PruneAlpha of tree must
be nonempty. In other words, grow tree by setting 'Prune','on',
or by pruning tree using prune.

Example: 'Subtrees','all'

Data Types: single | double | char | string

Output Arguments

label

The response tree predicts for the training
data. label is the same data type as the training
response data tree.Y.

If the Subtrees name-value argument contains m>1 entries, label has m columns,
each of which represents the predictions of the corresponding subtree.
Otherwise, label is a vector.

The classification tree has four pruning levels. Level 0 is the full, unpruned tree (as displayed). Level 4 is just the root node (i.e., no splits).

Estimate the posterior probabilities for each class using the subtrees pruned to levels 1 and 3.

[~,Posterior] = resubPredict(Mdl,'SubTrees',[1 3]);

Posterior is an n-by- K-by- 2 array of posterior probabilities. Rows of Posterior correspond to observations, columns correspond to the classes with order Mdl.ClassNames, and pages correspond to pruning level.

Display the class posterior probabilities for iris 125 using each subtree.

More About

Posterior Probability

The posterior probability of the classification at a node is
the number of training sequences that lead to that node with this
classification, divided by the number of training sequences that lead
to that node.

For example, consider classifying a predictor X as true when X<0.15 or X>0.95,
and X is false otherwise.

The pruned tree correctly classifies observations
that are less than 0.15 as true. It also correctly
classifies observations between .15 and .94 as false.
However, it incorrectly classifies observations that are greater than
.94 as false. Therefore the score for observations
that are greater than .15 should be about .05/.85=.06 for true,
and about .8/.85=.94 for false.

Indeed,
every value of X (the rightmost column) that is
less than 0.15 has associated scores (the left and center columns)
of 0 and 1, while the other
values of X have associated scores of 0.94 and 0.06.

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.