mdl = fitrtree(X, Y)
mdl = fitrtree(X, Y, Name, Value)
yfit = predict(mdl, Xnew)
[yfit, node] = predict(mdl, Xnew)
fitrtree creates a RegressionTree object from numeric predictors X and numeric response Y.
Name-value arguments include MaxNumSplits, MinLeafSize, MinParentSize, PredictorNames, and ResponseName. Numeric predictors are split with binary threshold tests that reduce squared error.
X = [0; 1; 2; 3; 4; 5];
Y = [1; 1.2; 3; 3.2; 9; 9.1];
mdl = fitrtree(X, Y, 'MaxNumSplits', 2);
yfit = predict(mdl, [1.5; 4.5])
| Version | Description |
|---|---|
| 2.0.0 | initial version |