Documentation Center

  • Trial Software
  • Product Updates

compact

Class: RegressionTree

Compact regression tree

Syntax

ctree = compact(tree)

Description

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

Input Arguments

tree

A regression tree created using fitrtree.

Output Arguments

ctree

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.

Examples

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

See Also

| | |

Was this topic helpful?