mdl = fitctree(X, Y)
mdl = fitctree(X, Y, Name, Value)
label = predict(mdl, Xnew)
[label, score, cost, node] = predict(mdl, Xnew)
fitctree creates a ClassificationTree object from numeric predictors X and class labels Y.
Name-value arguments include ClassNames, Prior, SplitCriterion, MaxNumSplits, MinLeafSize, and MinParentSize. Numeric predictors are split with binary threshold tests. Prediction returns leaf class scores.
X = [0 0; 0 1; 1 0; 1 1; 5 5; 5 6; 6 5; 6 6];
Y = [1; 1; 1; 1; 2; 2; 2; 2];
mdl = fitctree(X, Y);
[label, score] = predict(mdl, [0.2 0.1; 5.2 5.1])
| Version | Description |
|---|---|
| 2.0.0 | initial version |