Main Content

compact

Class:ClassificationTree

Compact tree

Syntax

ctree = compact(tree)

Description

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

Input Arguments

tree

A classification tree created usingfitctree.

Output Arguments

ctree

A compact decision tree.ctreehas classCompactClassificationTree. You can predict classifications usingctreeexactly as you can usingtree. However, sincectreedoes not contain training data, you cannot perform some actions, such as cross validation.

Examples

expand all

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

loadfisheririsfulltree = fitctree(meas,species); ctree = compact(fulltree); b = whos('fulltree');% b.bytes = size of fulltreec = whos('ctree');% c.bytes = ctree的大小[b.bytes c.bytes]% shows ctree uses half the memory
ans =1×211762 5097

Extended Capabilities