Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Using decision tree to consolidate levels of a class variable

Accepted Solution Solved
Reply
Contributor
Posts: 37
Accepted Solution

Using decision tree to consolidate levels of a class variable

[ Edited ]

Hi everyone,

I have successfully used a decision tree to consolidate(collapse) the levels of a categorical variable, Region. The process flow is as shown in the first attachment. I would like this new variable with collapsed levels to automatically serve as input to the proceeding node, say a regression node. I know I can do this manually using the replacement editor but is it possible to have SAS create a new variable with the new collapsed levels?

 

Second, my decision tree (image two) show me the leaves but the leaves dont show all the levels of the categorical variable. What could I do to actually see all the levels which make up the leaves?

Thanks,

 

Paul


one.JPGtwo.JPG

Accepted Solutions
Solution
‎07-07-2017 09:02 AM
SAS Super FREQ
Posts: 306

Re: Using decision tree to consolidate levels of a class variable

You just need to connect the Regression (or other modeling) node after the Decision Tree, and it will use all your original inputs plus the new leaf id (_NODE_) variable.  You can always use a Metadata node to change the roles of any of your variables mid-flow as well.

View solution in original post


All Replies
SAS Super FREQ
Posts: 306

Re: Using decision tree to consolidate levels of a class variable

You should see a property called Leaf Role in the Decision Tree node, and you can set that to be Input to use this _NODE_ variable, which represents your collapsed levels, in subsequent nodes.

 

And you can look at the Node Rules (under View>Model) or the score code (Scoring>SAS Code) in the Decision Tree results to see the full rules with all levels.

 

Hope that helps!

Wendy

Contributor
Posts: 37

Re: Using decision tree to consolidate levels of a class variable

Posted in reply to WendyCzika

Thanks Wendy,

And this is not very related to the first questions. After consolidating levels of a class variable using a tree and setting the properties of the tree to act as an input to a model, how can one bring in that new input (from tree consolidation) alongside other inputs(which are not outputs of the tree consolidation) into a node like the regression node?

 

Solution
‎07-07-2017 09:02 AM
SAS Super FREQ
Posts: 306

Re: Using decision tree to consolidate levels of a class variable

You just need to connect the Regression (or other modeling) node after the Decision Tree, and it will use all your original inputs plus the new leaf id (_NODE_) variable.  You can always use a Metadata node to change the roles of any of your variables mid-flow as well.

Contributor
Posts: 37

Re: Using decision tree to consolidate levels of a class variable

Posted in reply to WendyCzika

Hi Wendy,

This might be a big ask but say I had three variables (Post Code, Region, income_group) for which I wanted to consolidate their levels using a decision tree. An approach will be using three decision tree nodes for the three variables. However, is it possible to use a single decision tree node, and then maybe change certain properties to allow the tree node to produce three separate new variables for the collapsed levels of those three variables?

 

This

Contributor
Posts: 37

Re: Using decision tree to consolidate levels of a class variable

Posted in reply to WendyCzika

Thanks Wendy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 378 views
  • 1 like
  • 2 in conversation