I have a model that I train on same data, but i want a feature to have a stronger weight.

Say I have three features:

Car manufacturer's name
Top speed

and I want to classify my cars as "Sport", "Luxury", "Family", "Compact" using these indicators. However, say that I realise the manufacturer's name is the strongest indicator, so I want that to weigh more. For example, if I buy a Ferrari, that is a sport car, even though the price tag may make it look like a luxury car. So, while I want to use all features, I want one of them to have a stronger weight (this is just a silly example, my actual problem is different, but this gives an idea). If a manufacturer makes all 4 kinds, speed and price are important, otherwise the name should have a stronger weight than the price and top speed. Basically, my tree should really look at the manufacturer's name and then split depending on the other features.

Can I set up sklearn in python to do this? How?

  • $\begingroup$ Not entirely sure but, I think you have to tune the min_weight_fraction_leaf parameter by providing some sample weights. $\endgroup$
    – user-116
    Oct 11, 2017 at 12:21
  • $\begingroup$ @RahulAedula Thank you, I tried to read the documentation, but I am quite confused, especially since it looks like you pass in it a single float value. $\endgroup$
    – user
    Oct 12, 2017 at 1:32

1 Answer 1


You can create hierarchical models. The first model in the hierarchy would only get the single feature. The next model in the hierarchy would get the other features.

Scikit-learn does not support hierarchical modeling by default. You would have to write custom code.

  • $\begingroup$ +1, another way is to just put in redundant features (I always thought this would be a good extension to RF algorithms, input a set of weights/rules for the random feature selection). $\endgroup$
    – Andy W
    Apr 27, 2023 at 12:29

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.