Classify observations using decision tree classifier
Statistics and Machine Learning Toolbox / Classification
Import a trained classification object into the block by specifying the name of a workspace variable that contains the object. The input port x receives an observation (predictor data), and the output port label returns a predicted class label for the observation. You can add an optional output port score that returns predicted class scores or posterior probabilities.
label — Predicted class label
Predicted class label, returned as a scalar. The predicted class is the class that
minimizes the expected classification cost. For more details, see the More About
section of the
predict function reference page.
fixed point |
score — Predicted class scores or posterior probabilities
Predicted class scores or posterior probabilities, returned as a row vector of size 1-by-k, where k is the number of classes in the tree model.
The classification score of a leaf node is the posterior probability of the classification at the node. The posterior probability of the classification at a node is the number of training observations that lead to the node with the classification, divided by the number of training observations that lead to the node.
To check the order of the classes, use the
property of the tree model specified by
Select trained machine
To enable this port, select the check box for
Add output port for
predicted class scores on the Main tab of the
Block Parameters dialog box.
Add output port for predicted class scores — Add second output port for predicted class scores
off (default) |
Select the check box to include the second output port score in the ClassificationTree Predict block.
|Type: character vector|
Data TypesFixed-Point Operational Parameters
You can use a MATLAB Function block with the
predict object function of a classification tree object (
CompactClassificationTree). For an example, see
Predict Class Labels Using MATLAB Function Block.
When deciding whether to use the ClassificationTree Predict block in the
Statistics and Machine Learning Toolbox™ library or a MATLAB Function block with the
predict function, consider the
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
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.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Design and simulate fixed-point systems using Fixed-Point Designer™.
- ClassificationSVM Predict | ClassificationEnsemble Predict | ClassificationNeuralNetwork Predict | RegressionTree Predict
- Predict Class Labels Using ClassificationSVM Predict Block
- Predict Class Labels Using ClassificationEnsemble Predict Block
- Predict Class Labels Using ClassificationNeuralNetwork Predict Block
- Predict Class Labels Using MATLAB Function Block
- Identify Punch and Flex Hand Gestures Using Machine Learning Algorithm on Arduino Hardware (Simulink Support Package for Arduino Hardware)