ctree = compact(tree)
A regression tree created using RegressionTree.fit.
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 = RegressionTree.fit(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