दो explanatory variables के साथ Logistic regression
Logistic regression में कई explanatory variables भी शामिल किए जा सकते हैं। Logistic regression मॉडल में कई explanatory variables जोड़ने के लिए सिंटैक्स वही है जो linear regression के लिए होता है.
यहाँ आप डेटासेट के दोनों explanatory variables के साथ churn status का एक मॉडल फिट करेंगे: ग्राहक संबंध की अवधि और खरीदारी की नवीनता, और उनके बीच का इंटरैक्शन.
churn उपलब्ध है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Regression with statsmodels in Python
अभ्यास निर्देश
statsmodels.formula.apiसेlogit()फंक्शन इम्पोर्ट करें.- churn status
has_churnedका logistic regression फिट करें, जहाँ explanatory variables हैं: ग्राहक संबंध की अवधिtime_since_first_purchase, खरीदारी की नवीनताtime_since_last_purchase, और इन explanatory variables के बीच का एक interaction.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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)