BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
frupaul
Quartz | Level 8

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
1 ACCEPTED SOLUTION

Accepted Solutions
WendyCzika
SAS Employee

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

5 REPLIES 5
WendyCzika
SAS Employee

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

frupaul
Quartz | Level 8

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?

 

WendyCzika
SAS Employee

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.

frupaul
Quartz | Level 8

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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