Logistic Regression: Odds Ratios & Customer Churn Prediction0%

Logistic Regression: Odds Ratios & Customer Churn Prediction

Beginner12 min read•Updated: Jul 11, 2026
Study Materials

Logistic Regression: Odds Ratios & Customer Churn Prediction

While linear regression predicts continuous numerical outcomes, Logistic Regression is the industry standard for modeling binary categorical decisions (e.g., Churn vs Retain, Fraud vs Legitimate, Default vs Repay). By compressing linear combinations through the Sigmoid (Logit) function, logistic regression outputs calibrated probabilities bounded strictly between 0 and 1.


1. The Sigmoid Function & Log-Odds

A standard linear equation can produce predictions from $-\infty$ to $+\infty$, which is mathematically invalid for probabilities. Logistic regression applies the Sigmoid activation function:

$$P(Y=1 | X) = \sigma(z) = \frac{1}{1 + e^{-z}}$$

Where $z = \beta_0 + \beta_1 X_1 + \dots + \beta_p X_p$.

Log-Odds (Logit):

$$\ln\left(\frac{p}{1 - p}\right) = \beta_0 + \beta_1 X_1 + \dots + \beta_p X_p$$

  • $\frac{p}{1-p}$ is the Odds Ratio.
  • Exponentiating a coefficient $e^{\beta_j}$ reveals the multiplicative effect on customer churn odds for each unit change in $X_j$.

2. Building a Customer Churn Predictor

Python
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
 
X = df[['monthly_charges', 'tenure_months', 'num_support_tickets', 'contract_is_annual']]
y = df['churned'] # 1 = Churned, 0 = Active
 
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.20, random_state=42, stratify=y
)
 
# Best practice: always scale features for Logistic Regression
churn_pipeline = Pipeline([
('scaler', StandardScaler()),
('clf', LogisticRegression(random_state=42))
])
 
churn_pipeline.fit(X_train, y_train)
 
# Predict probabilities (not just hard 0 or 1 labels!)
churn_probs = churn_pipeline.predict_proba(X_test)[:, 1]

3. Interpreting Odds Ratios for Business Strategy

Python
# Extract coefficients and odds ratios
coefficients = churn_pipeline.named_steps['clf'].coef_[0]
odds_ratios = np.exp(coefficients)
 
results = pd.DataFrame({
'Feature': X.columns,
'Log-Odds (Coef)': coefficients.round(3),
'Odds Ratio (exp)': odds_ratios.round(3)
}).sort_values(by='Odds Ratio (exp)', ascending=False)
 
print(results)

Example Insights:

  • If num_support_tickets has an Odds Ratio of 1.85: Each additional customer support ticket increases churn odds by 85%.
  • If contract_is_annual has an Odds Ratio of 0.32: Annual contracts reduce churn odds by 68% compared to monthly contracts!

4. Probability Threshold Tuning

By default, predict() classifies cases as positive if $P \ge 0.50$. In customer retention, proactively reaching out to high-risk customers might warrant a lower threshold (e.g., $P \ge 0.35$):

Python
# Custom business threshold: Flag at 35% churn risk
custom_predictions = (churn_probs >= 0.35).astype(int)

Interactive Quiz

Multiple Choice Questions

Question 1
What mathematical function maps real numbers from $(-\infty, +\infty)$ to the probability interval $[0, 1]$ in logistic regression?
Question 2
In a churn prediction model, if a feature has an Odds Ratio of $e^{\beta} = 1.0$, what is its impact on customer churn?
Question 3
Why is feature scaling (e.g., StandardScaler) essential before fitting a regularized Logistic Regression model in Scikit-Learn?
Question 4
What does model.predict_proba(X_test)[:, 1] return in Scikit-Learn binary classification?
Question 5
If a telecommunications company wants to proactively identify as many potential churners as possible and is willing to accept a few false alarms, how should they adjust the decision threshold?

Next Lesson

Classification Metrics: Confusion Matrix, Precision, Recall, F1 & ROC-AUC

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext