fitrtree
Fit a regression decision tree.
📝Syntax
mdl = fitrtree(X, Y)
mdl = fitrtree(X, Y, Name, Value)
yfit = predict(mdl, Xnew)
[yfit, node] = predict(mdl, Xnew)
📄Description

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.

💡Examples
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])
🔗See Also
fitctreefitlmfitglm
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub