Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

cutcategories

Class: classregtree

Cut categories

classregtree will be removed in a future release. See fitctree, fitrtree, ClassificationTree, or RegressionTree instead.

Syntax

C = cutcategories(t)
C = cutcategories(t,nodes)

Description

C = cutcategories(t) returns an n-by-2 cell array C of the categories used at branches in the decision tree t, where n is the number of nodes. For each branch node i based on a categorical predictor variable x, the left child is chosen if x is among the categories listed in C{i,1}, and the right child is chosen if x is among those listed in C{i,2}. Both columns of C are empty for branch nodes based on continuous predictors and for leaf nodes.

C = cutcategories(t,nodes) takes a vector nodes of node numbers and returns the categories for the specified nodes.

Examples

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 elseif Cyl in {6 8} then node 3 else USA
 2  if MPG<31.5 then node 4 elseif MPG>=31.5 then node 5 else USA
 3  if Cyl=6 then node 6 elseif Cyl=8 then node 7 else USA
 4  if MPG<21.5 then node 8 elseif MPG>=21.5 then node 9 else USA
 5  if MPG<41 then node 10 elseif MPG>=41 then node 11 else Japan
 6  if MPG<17 then node 12 elseif MPG>=17 then node 13 else USA
 7  class = USA
 8  class = France
 9  class = USA
10  class = Japan
11  class = Germany
12  class = Germany
13  class = USA
view(t)

C = cutcategories(t)
C = 
    [4]    [1x2 double]
     []              []
    [6]    [         8]
     []              []
     []              []
     []              []
     []              []
     []              []
     []              []
     []              []
     []              []
     []              []
     []              []
C{1,2}
ans =
     6     8

References

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

Was this topic helpful?