Foundations of Probability in Python
Alexander A. Ramírez M.
CEO @ Synergy Vision
$$ logistic(t) = logistic(slope*x + intercept) $$
# Import LogisticRegression
from sklearn.linear_model import LogisticRegression
# sklearn logistic model
model = LogisticRegression(C=1e9)
model.fit(hours_of_study, outcomes)
# Get parameters
beta1 = model.coef_[0][0]
beta0 = model.intercept_[0]
# Print parameters
print(beta1, beta0)
(1.3406531235010786, -15.05906237996095)
hours_of_study_test = [[10]]
outcome = model.predict(hours_of_study_test)
print(outcome)
array([False])
$$ $$
# Put value in an array
value = np.asarray(9).reshape(-1,1)
# Calculate the probability for 9 hours of study
print(model.predict_proba(value)[:,1])
array([0.04773474])
Foundations of Probability in Python