Python Statsmodel.api Logistic Regression (logit)
So I'm trying to do a prediction using python's statsmodels.api to do logistic regression on a binary outcome. I'm using Logit as per the tutorials. When I try to do a prediction o
Solution 1:
The predicted values are the probabilies given the explanatory variables, more precisely the probability of observing 1.
To get a 0, 1 prediction, you need to pick a threshold, like 0.5 for equal thresholding, and assign 1 to the probabilities above the threshold.
With numpy this would be for example
predicted = results.predict(x_for_prediction)
predicted_choice = (predicted > threshold).astype(int)
Post a Comment for "Python Statsmodel.api Logistic Regression (logit)"