# predict

Predict labels using classification tree

## Syntax

## Description

`[`

uses any of the input argument combinations in the previous syntaxes and additionally returns:`label`

,`score`

,`node`

,`cnum`

]
= predict(___)

A matrix of classification scores (

`score`

) indicating the likelihood that a label comes from a particular class. For classification trees, scores are posterior probabilities. For each observation in`X`

, the predicted class label corresponds to the minimum expected misclassification cost among all classes.A vector of predicted node numbers for the classification (

`node`

).A vector of predicted class number for the classification (

`cnum`

).

## Examples

## Input Arguments

## Output Arguments

## More About

## Algorithms

`predict`

generates predictions by following the branches
of `Mdl`

until it reaches a leaf node or a missing value. If `predict`

reaches a leaf node, it returns the classification of that
node.

If `predict`

reaches a node with a missing value for a
predictor, its behavior depends on the setting of the `Surrogate`

name-value
argument when `fitctree`

constructs `Mdl`

.

(default) —`Surrogate`

=`"off"`

`predict`

returns the label with the largest number of training samples that reach the node.—`Surrogate`

=`"on"`

`predict`

uses the best surrogate split at the node. If all surrogate split variables with positive*predictive measure of association*are missing,`predict`

returns the label with the largest number of training samples that reach the node. For a definition, see Predictive Measure of Association.

## Alternative Functionality

### Simulink Block

To integrate the prediction of a classification tree model into Simulink^{®}, you can use the ClassificationTree
Predict block in the Statistics and Machine Learning Toolbox™ library or a MATLAB^{®} Function block with the `predict`

function. For examples,
see Predict Class Labels Using ClassificationTree Predict Block and Predict Class Labels Using MATLAB Function Block.

When deciding which approach to use, consider the following:

If you use the Statistics and Machine Learning Toolbox library block, you can use the Fixed-Point Tool (Fixed-Point Designer) to convert a floating-point model to fixed point.

Support for variable-size arrays must be enabled for a MATLAB Function block with the

`predict`

function.If you use a MATLAB Function block, you can use MATLAB functions for preprocessing or post-processing before or after predictions in the same MATLAB Function block.

## Extended Capabilities

## Version History

**Introduced in R2011a**

## See Also

`fitctree`

| `compact`

| `prune`

| `loss`

| `edge`

| `margin`

| `CompactClassificationTree`

| `ClassificationTree`