| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
Class counts
P = classcount(t)
P = classcount(t,nodes)
P = classcount(t) returns an n-by-m array P of class counts for the nodes in the classification tree t, where n is the number of nodes and m is the number of classes. For any node number i, the class counts P(i,:) are counts of observations (from the data used in fitting the tree) from each class satisfying the conditions for node i.
P = classcount(t,nodes) takes a vector nodes of node numbers and returns the class counts for the specified nodes.
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 elseif PL>=2.45 then node 3 else setosa
2 class = setosa
3 if PW<1.75 then node 4 elseif PW>=1.75 then node 5 else versicolor
4 if PL<4.95 then node 6 elseif PL>=4.95 then node 7 else versicolor
5 class = virginica
6 if PW<1.65 then node 8 elseif PW>=1.65 then node 9 else versicolor
7 class = virginica
8 class = versicolor
9 class = virginica
view(t)

P = classcount(t)
P =
50 50 50
50 0 0
0 50 50
0 49 5
0 1 45
0 47 1
0 2 4
0 47 0
0 0 1[1] Breiman, L., J. Friedman, R. Olshen, and C. Stone. Classification and Regression Trees. Boca Raton, FL: CRC Press, 1984.

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |