Class: RegressionTree

Compact regression tree


ctree = compact(tree)


ctree = compact(tree) creates a compact version of tree.

Input Arguments


A regression tree created using fitrtree.

Output Arguments


A compact regression tree. ctree has class CompactRegressionTree. You can predict regressions using ctree exactly as you can using tree. However, since ctree does not contain training data, you cannot perform some actions, such as cross validation.


Compare the size of a regression tree for the carsmall data to the compact version of the tree:

load carsmall
X = [Acceleration Cylinders Displacement Horsepower Weight];
fulltree = fitrtree(X,MPG);
ctree = compact(fulltree);
b = whos('fulltree'); % b.bytes = size of fulltree
c = whos('ctree'); % c.bytes = size of ctree
[b.bytes c.bytes] % shows ctree uses 2/3 the memory

ans =
       15715       10258
Was this topic helpful?