numnodes - Number of nodes

Class

@classregtree

Syntax

n = numnodes(t)

Description

n = numnodes(t) returns the number of nodes n in the tree t.

Example

Create a classification tree for Fisher's iris data:

load fisheriris;

t = classregtree(meas,species,...
                 'names',{'SL' 'SW' 'PL' 'PW'})
t = 
Decision tree for classification
1  if PL<2.45 then node 2 else node 3
2  class = setosa
3  if PW<1.75 then node 4 else node 5
4  if PL<4.95 then node 6 else node 7
5  class = virginica
6  if PW<1.65 then node 8 else node 9
7  class = virginica
8  class = versicolor
9  class = virginica

view(t)

n = numnodes(t)
n =
     9

Reference

[1] Breiman, L., et al., Classification and Regression Trees, Chapman & Hall, Boca Raton, 1993.

See Also

classregtree

  


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