# Is it ok a threshold of 0?

I am dealing with a classification problem with a dataset containing 60k rows: 69k are negative class, and 1k is positive. I trained my models and I obtained the confusion matrices with a threshold of 0.5 (by default). If I decrease the threshold results improve. I found that the best results are with threshold 0. But what does it mean threshold 0, is it useful? Or is it better also a threshold of 0.01 with slightly worse?

EDIT:

• A threshold of $0$ means that you call every observation category $1$, so you get the higher accuracy by ignoring what you observe and calling everything $1$ than you do by following your model output. What ROCAUC do you get?
– Dave
Commented Jan 15, 2021 at 19:09
• @Dave I edited the post with all the info. So you are suggesting to avoid threshold 0, right? Commented Jan 15, 2021 at 19:19
• What is the metric you are optimizing? What is the purpose of this classifier? How it would be used? How do the predictions translate to solving a business problem?
– Tim
Commented Oct 12, 2022 at 7:42

You can plot the ROC curve and the point that makes max the TPR and min the FPR. It does not requiere too much code, but I don't know if code is allowed in this channel. Another solution could be to rebalance the target distribution. There are some methods to achieve this. Take a look at SMOTE

Talking about threshold = 0, as Dave and Mark has said, it would mean that your model would classify EVERY observation into one group, totally ignoring the other one. IMO, this would make the model senseless, since you don't need a model to "predict" always the same value, so I would avoid threshold = 0 (or = 1)

– Dave
Commented Jan 15, 2021 at 19:43
• Yeah, I agree with him, is not the best option. I would try to avoid changing the data as much as possible, but some people don't mind doing it. Commented Jan 15, 2021 at 19:49
• Yes, I have already done steps like SMOTE and ROC curve. I just wanted to understand if i could accept a threshold of 0. My dataset also after SMOTE is highly umbalanced and my platform, Microsoft Azure, can not do undersampling. So I will use a threshold of 0.01-0.1. Thank you Commented Jan 15, 2021 at 20:46

For a highly unbalanced data set like yours, a model that always predicts 1 (as Dave was discussing) will always have high values for the metrics you're displaying. You need to focus on the negative predictions; if the interface you're using allows the selection of the metric true negative rate (also called specificity or selectivity) use that. If such an option is not available, see if you can switch from identifying 1 as the positive label to identifying 1 as the negative label; I think that would put the focus on the negative labels where it belongs.

• No Microsoft Azure does not have the metrics of specificity and sensitivity. I have not understood the solution that you proposed.. Commented Jan 15, 2021 at 20:47
• Your screen shot shows, "Positive label 0 Negative label 1". Does the interface give you the ability to switch that, so it's "Positive label 1 Negative label 0"? Commented Jan 15, 2021 at 22:20
• Looking at your positive and negative counts by score bin, it seems your model does a reasonable job of identifying negative cases. What are the values of the metrics if you leave the threshold at the default value of 0.5? Commented Jan 15, 2021 at 22:58
• I can do all the analysis again, saying "pos" = 0 and "neg" = 1. But I have not understood what does it change in this way... Commented Jan 16, 2021 at 14:25
• Post the results and we can discuss it. Commented Jan 19, 2021 at 15:25

I had come cross similar imbalanced data recently and by using F1 score metrics, I picked up 0.09 as best classification threshold. So as other suggests, you should use other metrics (F1 score in scikit) to decide best threshold.

I also observed SMOTE provides reasonable results for imbalanced data.