Logistic Regression Basics: Predicting Purchase from Session Count
logistic regression, odds ratio, purchase prediction, conversion, session behaviour
TL;DR: Purchase probability rises from 14% (1 session) to 52% (8 sessions) (n=1,500), OR per session = 1.31 [1.22, 1.40], McFadden R² = 0.036, AIC = 1,570. Decision: each extra session raises purchase odds by 31%, so engage users across multiple visits.
Answer
Method: Logistic regression for binary outcome.
Estimate: OR = 1.31 per session and CI 1.22, 1.40.
Data: User behaviour, variables sessions, purchased, n = 1,500.
Action: Each extra session raises purchase odds by 31%. Encourage repeat visits.
Case
You are analysing customer behaviour for an e-commerce platform and want to understand: Does the number of on-site sessions influence the likelihood of making a purchase? Specifically, how much do purchase odds increase with each additional session? Can you predict purchase probability from session count to identify customers most likely to buy?
Dataset
Synthetic sample from customer session data (Schema B).
| Variable | Label | Value |
|---|---|---|
sessions |
Number of sessions | Count (0+) |
purchase |
Purchase made | 0 (No), 1 (Yes) |
n |
Number of customers | 1,500 |
| Distribution | Mean sessions | ≈3 (Poisson λ=3) |
Method
We use logistic regression to model the relationship between session count (predictor) and purchase outcome (binary response). Unlike linear regression, logistic regression models the log-odds (logit) of the outcome:
\[ \log\left(\frac{p}{1-p}\right) = \beta_0 + \beta_1 \times \text{Sessions}, \]
where \(p\) is the probability of purchase. Rearranging gives the predicted probability:
\[ p = \frac{1}{1 + e^{-(\beta_0 + \beta_1 \times \text{Sessions})}}. \]
The odds ratio (OR) for a one-unit increase in sessions is: \[ \text{OR} = e^{\beta_1}. \]
An OR > 1 indicates increased odds of purchase with more sessions, and an OR < 1 indicates decreased odds. We report 95% Wald confidence intervals for the odds ratio.
Interpretation guide: - OR = 1.00: No effect - OR = 1.31: 31% increase in odds per additional session - OR = 2.00: 100% increase (doubling) in odds - OR = 0.80: 20% decrease in odds
Calculation
Visualisation
Results and Interpretation
The logistic regression reveals a statistically significant positive relationship between session count and purchase probability. The estimated slope coefficient is β₁ = 0.268 (SE = 0.035, z = 7.58, p < .001), which translates to an odds ratio of 1.31 (95% CI [1.22, 1.40]) (R Core Team 2024).
Odds ratio interpretation: For every additional session, the odds of making a purchase increase by 31%. Customers with 2 sessions have 1.31 times the odds of purchasing of customers with 1 session, holding all else constant. The 95% CI [1.22, 1.40] places the true effect between a 22% and a 40% increase in odds per session.
Probability predictions: - 1 session: Predicted purchase probability = 14.2% - 3 sessions (mean): Predicted purchase probability = 22.0% - 5 sessions: Predicted purchase probability = 32.6% - 8 sessions: Predicted purchase probability = 51.9%
The model shows purchase probability increases non-linearly with sessions, following a logistic S-curve. Customers with 4 or more sessions pass 25% purchase probability, against about 14% for single-session visitors. Overall, 23.2% of the 1,500 customers bought.
Model fit: The McFadden pseudo R² of 0.036 (3.6%) indicates the model explains a modest portion of variance in purchase outcomes. This is typical for individual-level behavioural models where pseudo R² values of 2-15% are often acceptable, because many factors beyond session count influence purchase decisions. The residual deviance (1,565.9) is lower than the null deviance (1,625.0) by 59.1 on 1 degree of freedom, so the model improves clearly on the intercept-only baseline.
Statistical significance: The Wald z-test for the slope, z = 7.58, p < .001, gives strong evidence that session count predicts purchase probability.
Decision framework. The positive relationship between sessions and purchase probability suggests 5 actionable steps: (1) Engagement strategies: Encourage multi-session visits through retargeting, email reminders or personalised recommendations, (2) Customer segmentation: Treat 1-session visitors differently from 5+ session visitors in targeting and messaging, (3) Lead scoring: Use session count as a component of lead quality scores, (4) Conversion optimisation: Focus conversion tactics on high-session users with the highest predicted purchase probability (above 25%), (5) Further analysis: Extend the model with additional predictors (device type, traffic source, time on site) to improve predictions and understand interaction effects.
Predicted Probabilities by Session Count
Assumptions
Logistic regression assumes:
- Binary outcome: Purchase is coded as 0 (no purchase) or 1 (purchase)
- Independence: Each customer’s purchase decision is independent of others
- Linearity of log-odds: The relationship between sessions and log-odds of purchase is linear (can test with polynomial terms)
- Overlap between outcomes: Every session count includes both buyers and non-buyers, so the predictor leaves the outcomes overlapping
- Large sample size: Generally requires n ≥ 10 events per predictor (1,500 observations with 1 predictor is adequate)
Note: Normal residuals and homoscedasticity are linear-regression assumptions, and logistic regression drops both.
Limitations
This analysis leaves out:
- Confounding variables: Device type, traffic source, time spent per session, page views, product browsing behaviour
- Time effects: Session timing (same day vs. spread over weeks), recency effects, seasonality
- Customer heterogeneity: New vs. returning customers, demographics, purchase history
- Non-linear effects: Diminishing returns at very high session counts (may plateau beyond 8-10 sessions)
- Model calibration: Predicted probabilities need validation on held-out data before they can be trusted
- Interaction effects: Session impact may vary by customer segment or traffic source
- Causality: Correlation stops short of proving that sessions cause purchases. Customers who already plan to buy may browse more.
Recommendations for improvement: - Add categorical predictors (device type, traffic source) and test interactions with sessions - Include continuous predictors (average time per session, pages viewed, cart additions) - Test polynomial terms (sessions²) or splines for non-linear relationships - Split data into training/test sets to assess out-of-sample prediction accuracy - Calculate AUC-ROC and calibration curves to evaluate discrimination and calibration - Consider hierarchical models if sessions are nested within customers over time - Use propensity score matching or causal inference methods to estimate treatment effects
Model Diagnostics
Diagnostic interpretation: Panel A shows agreement between observed and predicted purchase rates across session counts (points should fall near diagonal line). Panel B shows deviance residuals should be randomly scattered around zero with no systematic pattern. Large deviations suggest model misspecification or influential outliers.
Use the below format to cite this page
Sharafuddin, M. A. (2025, October 25). Logistic regression basics: Predicting purchase from session count. Flair Marketing Intelligence (FlairMI). https://flairmi.com/blog/posts/06-logistic-basics.html
@online{sharafuddin2025-logistic,
author = {Sharafuddin, Mohammed Ali},
title = {Logistic Regression Basics: Predicting Purchase from Session Count},
year = {2025},
date = {2025-10-25},
url = {https://flairmi.com/blog/posts/06-logistic-basics.html},
langid = {en}
}
References
Citation
@online{ali_sharafuddin2025,
author = {Ali Sharafuddin, Mohammed},
title = {Logistic {Regression} {Basics:} {Predicting} {Purchase} from
{Session} {Count}},
date = {2025-10-25},
url = {https://flairmi.com/blog/posts/06-logistic-basics.html},
langid = {en}
}
Comments