cutvar - Cut variable names

Class

@classregtree

Syntax

v = cutvar(t)
v = cutvar(t,nodes)
[v,num] = cutvar(...)

Description

v = cutvar(t) returns an n-element cell array v of the names of the variables used for branching in each node of the tree t, where n is the number of nodes. These variables are sometimes known as cut variables. For leaf nodes, v contains an empty string.

v = cutvar(t,nodes) takes a vector nodes of node numbers and returns the cut variables for the specified nodes.

[v,num] = cutvar(...) also returns a vector num containing the number of each variable.

Example

Create a classification tree for car data:

load carsmall

t = classregtree([MPG Cylinders],Origin,...
                 'names',{'MPG' 'Cyl'},'cat',2)
t = 
Decision tree for classification
 1  if Cyl=4 then node 2 else node 3
 2  if MPG<31.5 then node 4 else node 5
 3  if Cyl=6 then node 6 else node 7
 4  if MPG<21.5 then node 8 else node 9
 5  if MPG<41 then node 10 else node 11
 6  if MPG<17 then node 12 else node 13
 7  class = USA
 8  class = France
 9  class = USA
10  class = Japan
11  class = Germany
12  class = Germany
13  class = USA

view(t)

[v,num] = cutvar(t)
v = 
    'Cyl'
    'MPG'
    'Cyl'
    'MPG'
    'MPG'
    'MPG'
    ''
    ''
    ''
    ''
    ''
    ''
    ''
num =
     2
     1
     2
     1
     1
     1
     0
     0
     0
     0
     0
     0
     0

Reference

[1] Breiman, L., J. Friedman, R. Olshen, and C. Stone. Classification and Regression Trees. Boca Raton, FL: CRC Press, 1984.

See Also

classregtree, numnodes, children

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS