1
$\begingroup$

I am using sklearn random forest to predict the probability of win/lose in a card game. There are 4 features in my data set. Can I set the depth of one feature to be 1 while the depth of other features to be higher?

Such that the output will be in the form: for every combination of the first 3 features, there will be a threshold $T$ of the 4th feature.

For every $X1,X2,X3$ the following is true:

  • if $X4<T$ then $y=0 $
  • if $X4 >= T$ then $y=1$

The reason is that this feature is the hand strength of the player and y (the winning probability) is monotonically increasing in the hand strength. Thus I wish to get to a cutoff decision: for every combination of the first three features (X1,X2,X3) there is a Threshold $T$ such that, for hand strength greater than $T$, play Right, and for hand strength lower than $T$, play Left.

I am doing my first steps in Machine learning, so i will appreciate a simple solution.

$\endgroup$
2
$\begingroup$

As far as I know (and see), sklearn random forest library doesn't have such an option, (i.e. use this feature only once). It also constructs many decision trees, instead of one, using different subsets of your features (as well as samples) every time, then aggregate their outputs to make decisions. So, you won't be able to extract a simple set of rules after you've trained your model if it is among your purposes. Other than that, I believe that monotonicity of $X_4$ will be somehow reflected in the random forest itself.

$\endgroup$
  • $\begingroup$ right, it is "somehow reflected" but not absolutely reflected, I might have to clean the output $\endgroup$ – Cohensius Dec 17 '18 at 13:51
1
$\begingroup$

You can try to use min_samples_split or min_samples_leaf to restrict depth without enforcing a hard cap like max_depth would. But you cannot enforce that there is always a single node for a particular feature.

$\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.