CommerceLens: Turning Customer Behavior Into a Probability Problem
A portfolio analytics product demonstrating the full path from raw session data to business decisions — descriptive statistics, association, conditional probability, Bayes' theorem, random variables, and distribution modeling, all computed live from a 60,000-session synthetic dataset.
Problem
E-commerce teams generate huge volumes of session-level behavioral data, but most internal dashboards stop at descriptive reporting: conversion rate, revenue, AOV. They rarely go further to ask the harder, probability-shaped questions a business actually needs answered to act with confidence under uncertainty:
- What is the probability a given type of session converts, and how does that change conditional on observed behavior?
- How many conversions should we expect from N future sessions, and how much should that estimate vary?
- If we sample a fixed number of customers from a finite campaign pool, what’s the chance we land enough high-value customers?
- Which behavioral signals are genuinely associated with purchase, and which are just noise or a confound?
CommerceLens builds a small analytics product that answers these questions directly, with every chart tied to an explicit business question and every number computed live from data rather than asserted.
Dataset
A synthetic but statistically realistic session-level e-commerce dataset, generated by a seeded, reproducible Python script (data/generate_dataset.py). Variables are intentionally correlated the way a real marketplace would be — add-to-cart raises purchase probability but doesn’t guarantee it; order value is right-skewed with a small tail of legitimately large orders; returning customers behave differently from new ones — with irreducible random noise layered on top so nothing is deterministic. Every relationship discussed on this site is verified against documented limitations, not presented as a real-world finding.
Approach
- Generate the dataset from scratch with a fixed seed (Python, numpy, pandas) and validate it (33 automated integrity checks — see Technical Implementation).
- Analyze with reusable, unit-tested Python modules — descriptive statistics, association, probability, Bayes, combinatorics, random variables, distributions, campaign sampling, and customer value — never inline math in the UI layer.
- Compute once, ship everywhere: a single script (
analytics/run_all.py) runs every module against the real data and writes one JSON payload. The website reads that payload — nothing on the site is hand-typed. - Build the product in Next.js/TypeScript with a parallel TypeScript analytics layer (mirroring the Python modules) so the interactive calculators — the Probability Engine, Conversion Forecast Simulator, Campaign Sampling tool, Distribution Lab — compute live, client-side, in response to user input.
- Frame every result as a business question: Business Question → Metric → Observation → Interpretation → Caveat, on every major chart.
Key Analyses
Key Findings
Business Implications
Every finding on this site is deliberately translated into a business decision with its assumptions made explicit — see the Decision Lab for the full What-did-we-observe / What-does-it-mean / What-decision-could-it-inform / What’s-the-limitation treatment applied to five real findings (discount exposure, cart behavior, segment differences, category return rates, and channel performance). The throughline: an observed association can inform where to test or invest next, but it does not by itself justify a causal claim or a guaranteed outcome.
Limitations
This is a demonstration of analytical method on a synthetic, observational dataset — not a real-world research finding. See the dedicated Limitations page for the full list: synthetic data, observational (non-experimental) design, distributional and independence assumptions, sample-dependent empirical probabilities, and the specific caveats for the binomial, hypergeometric, uniform, triangular, and exponential models used throughout.
Technical Implementation
Statistics & Probability Covered
Skills Demonstrated
Interactive Demo
The whole point of CommerceLens is that it’s not a static report — try it directly: