# Adjusting probability threshold for sklearn's logistic regression model

I am a 10th grade student working on a binary classification problem and I have decided to use the logistic regression model from Scikit-Learn. I am looking to predict patient adherence given the time of day, day of week, or both. I have simulated data and have made it so that certain timeslots have many more 0s (meaning the patient did not take the medicine) to simulate a trend, but my model is still predicting "1" for every single input. I believe my data is very imbalanced and without any class weights, the model puts every input into the "1" class. Obviously, this results in terrible accuracy, AUC and everything in between. Sklearn does have a class_weight parameter, but since that is dichotomous and only gives the "balanced" option, it really does not help and in some cases makes accuracy far worse than just assuming everything to be in the 1 class. I think changing the threshold to 0.75 will work, given what I have seen from the data, but I can't find anything about adjusting the threshold in any documentation.

Is there anyway to adjust this threshold? Or any other way to deal with my imbalanced data?

Let me know if you want me to elaborate on the specifics of my data.

decisions = (model.predict_proba() >= mythreshold).astype(int)

• Good answer. I took the liberty of putting your snipped into a code block, and (a bit more borderline of an edit) changed your * 1 to astype(int) since it's a bit more self explanatory. Feel free to edit back if you prefer the * 1. – Matthew Drury Dec 31 '18 at 1:55