# How to enforce a monotonic answer in a single feature in a Binary classification problem

I am trying to use sklearn Random forest to predict the probability of win/lose in a card game. There are 4 features in my data set. Feature $$X_4$$ is the hand strength of the player and y (the winning probability) is monotonically increasing in the hand strength. Thus I have a cutoff decision: for every combination of the first three features $$(X_1,X_2,X_3)$$ there is a Threshold $$T$$ such that, for $$X_4 > T$$, play Right, otherwise play Left.

The prediction isn't monotonic, that is, for some $$(X_1,X_2,X_3, X_4=x')$$ the predicted label is $$1$$ however for $$(X_1,X_2,X_3, X_4=x'')$$ where $$x''>x'$$ the predicted label is $$0$$.

How can I enforce this monotonicity?

Should I use a different classifier? is DecisionTreeClassifier better suit this problem? my data labels are unbalanced at 65:35

• I’m not aware of a way to do this using sklearn unless you want to write the class yourself. However the xgboost library supports monotonicity in features.
– Sycorax
Dec 17, 2018 at 15:36
• You can use logistic regression, maybe representant $X_4$ with a (monotone) spline. Dec 17, 2018 at 21:43