BaşlayınÜcretsiz başlayın

Logistic regression with two explanatory variables

Logistic regression also supports multiple explanatory variables. To include multiple explanatory variables in logistic regression models, the syntax is the same as for linear regressions.

Here you'll fit a model of churn status with both of the explanatory variables from the dataset: the length of customer relationship and the recency of purchase, and their interaction.

churn is available.

Bu egzersiz, kursun bir parçasıdır

Intermediate Regression with statsmodels in Python

Kursa Göz Atın

Egzersiz talimatları

  • Import the logit() function from statsmodels.formula.api.
  • Fit a logistic regression of churn status, has_churned, versus length of customer relationship, time_since_first_purchase, and recency of purchase, time_since_last_purchase, and an interaction between the explanatory variables.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Import logit
____

# Fit a logistic regression of churn status vs. length of relationship, recency, and an interaction
mdl_churn_vs_both_inter = ____

# Print the coefficients
print(mdl_churn_vs_both_inter.params)
Kodu Düzenle ve Çalıştır