How do I display the rule in a regression tree in a different fashion than default?

8 views (last 30 days)
Currently the regression tree presents the splitting rules in the form of for example x33 < 23, x33 >=23 but I would like the rule to be presented as: x33 = {1,18, 20, 22} for the left branch and x33 = {23, 25, 30} for right branch. I.e. I want the subset of the numerical values that variable 33 can assume to be displayed for each branch. Can anyone help me with this? I'd really appreciate the help!

Answers (1)

Ilya
Ilya on 4 Apr 2012
You do not say what regression tree you are using. Let's assume you are using RegressionTree.
It is not clear what you mean by "I would like the rule to be presented as: x33 = {1,18, 20, 22}". If you want to view the rule presented in such a way on the graphical display, you would need to modify the VIEW method of the classregtree class. If you merely want to find the left and right subsets, here is what you can do:
load carsmall
t = RegressionTree.fit([Acceleration Cylinders],MPG,...
'PredictorNames',{'Accelaration' 'Cylinders'});
t.CutVar{1}
ans = Cylinders
t.CutPoint(1)
ans = 5
leftset = unique(Cylinders(Cylinders<t.CutPoint(1)))'
leftset = 4
rightset = unique(Cylinders(Cylinders>=t.CutPoint(1)))'
rightset = 6 8

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!