posts icon indicating copy to clipboard operation
posts copied to clipboard

Issue in post: "Stop using 0.5 as the threshold for your binary classifier"

Open Buedenbender opened this issue 1 year ago • 1 comments

Just spent my evening binge reading through your blog posts, so thank you very much for the entertainment / educational material. I spotted a minor mistake when trying to reproduce the code listing

from sklearn_evaluation.plot import ConfusionMatrix
# ...
cm_dot_five = ConfusionMatrix(y_test, y_pred)
cm_dot_five

Does not work, the following fixed it

from sklearn_evaluation import plot
# ...
cm_dot_five = plot.confusion_matrix(y_test, y_pred)
cm_dot_five

This error is repeated for the second ConfusionMatrix / confusion_matrix
I am not 100% sure but also I think the positional arguments should be true label / predicted label (y_test,y_pred) (docs), instead in the example below it looks like it is: (predicted_label_after_new_thresh,predicted_label)

cm_dot_four = ConfusionMatrix(y_score[:, 1] >= 0.4, y_pred)

Possible correction

cm_dot_four = plot.confusion_matrix(y_test, y_score[:, 1] >= 0.4)

Buedenbender avatar Mar 16 '23 21:03 Buedenbender

Hi @Buedenbender Thank you for raising this. Can take a look at it and implement your fix.

lfunderburk avatar May 01 '23 03:05 lfunderburk