Aan de slagGa gratis aan de slag

Logistic regression with logit()

Logistic regression requires another function from statsmodels.formula.api: logit(). It takes the same arguments as ols(): a formula and data argument. You then use .fit() to fit the model to the data.

Here, you'll model how the length of relationship with a customer affects churn.

churn is available.

Deze oefening maakt deel uit van de cursus

Introduction to Regression with statsmodels in Python

Cursus bekijken

Oefeninstructies

  • Import the logit() function from statsmodels.formula.api.
  • Fit a logistic regression of has_churned versus time_since_first_purchase using the churn dataset. Assign to mdl_churn_vs_relationship.
  • Print the parameters of the fitted model.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import logit
____

# Fit a logistic regression of churn vs. length of relationship using the churn dataset
mdl_churn_vs_relationship = ____

# Print the parameters of the fitted model
print(____)
Code bewerken en uitvoeren