How to return the probability over a prediction in Logistic Regression

I have built a logistic regression model to classify between 1 and 0 my predictions. My problem is more oriented over the probability of the prediction being 1 or the opposite over 0.

I really don’t master well how to manage the model to turn the answer over the probability percentage , example if my prediction is 1 , then the probability of the prediction being 1 is 80%.

Any thoughts or ideas about how to manage this situation?

Rather than think of it as “the probability of a 1/0 prediction” think of it as “what is the probability, and the threshold applied to that probability, that led to that 1/0 prediction”

I assume you are using sklearn’s https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression.predict_proba.

Almost every sklearn classifier has a model.predict_proba which gives you a 2D array of probabilities, each column representing 1 class and each row presenting one observation to be predicted, with the sum across each row to 1

People use model.predict_proba when they want to manually code a threshold of predicting 1. For eg, if threshold is 0.7, then values of predict_proba from [0.7,1) will be classified as 1. When people use model.predict, it’s because they are fine with the default >= 0.5 threshold for classifying it as 1.