I am working on a binary classification problem with 1000 rows and 20 variables.

I have variables like product_id, city, state, country, product family, product type, product segment etc etc..

As you can see that most of my variables are hierarchical variables. Meaning, if I know the city name, I can infer/populate other variables like state, country etc.

Same with product_id as well. If I know product_id info, I can get all info about product_family, product_segment, product type etc.

My questions are as follows

a) So, should I use only the granular level detail variables in my ML model and ignore other levels of same variable? because I guess it would be correlated

b) Any suggestion or tips on how can we handle this scenario in our model?

c) Should I drop this project because I only have very few granular level detail variables (and rest of it can be inferred based on them even without using AI)?

d) If I make a prediction, I believe the contribution of hierarchical variable is same. For ex: If variable city contributes to prediction by 10%, am I right that state, country all contribute the same 10% as well. (meaning all together contribute 10% to the outcome)

Can you help me with this please?v Looking forward to your inputs

  • $\begingroup$ Is that Aurora, CO, or Aurora, IL? Or Aurora, Suriname, or Aurora, Victoria or… And no, if the city is 10% it doesn’t imply the state or country is 10%—if all the Auroras are Aurora, Santa Catarina, but the remaining 80% of the data isn’t Brazil… $\endgroup$ May 20, 2023 at 18:30

1 Answer 1


Of course you could use only granular level variables but this would throw away a lot of information. The are different ways to leverage hierarchies. One way would be target encoding as described here Another possible solution would be the use of a hierarchical model. An example for a hierarchical regression problem is described here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.