This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Class: ClassificationTree

Compact tree


ctree = compact(tree)


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

Input Arguments


A classification tree created using fitctree.

Output Arguments


A compact decision tree. ctree has class CompactClassificationTree. You can predict classifications 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.


expand all

Compare the size of the classification tree for Fisher's iris data to the compact version of the tree.

load fisheriris
fulltree = fitctree(meas,species);
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 half the memory
ans = 1×2

       11613        4924