1
$\begingroup$

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
Price
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?

$\endgroup$
2
  • $\begingroup$ Not entirely sure but, I think you have to tune the min_weight_fraction_leaf parameter by providing some sample weights. $\endgroup$ Oct 11 '17 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 '17 at 1:32
0
$\begingroup$

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 natively support hierarchical modeling. You would have to write custom code.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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