CommerceLens
Case Study

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

Sessions
60,000
Columns
53
Unique Customers
20,284
Date Range
2024-01-01 – 2025-12-31

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

  1. Generate the dataset from scratch with a fixed seed (Python, numpy, pandas) and validate it (33 automated integrity checks — see Technical Implementation).
  2. 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.
  3. 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.
  4. 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.
  5. Frame every result as a business question: Business Question → Metric → Observation → Interpretation → Caveat, on every major chart.

Key Analyses

Key Findings

55.0%
P(Purchase | Add to Cart)
vs. a baseline conversion rate of 27.5% — sessions with a cart event convert at roughly 2.0x the baseline rate in this sample.
₹4,685
Average Order Value
vs. a median of ₹1,350 — the gap reflects a right-skewed order-value distribution with a small tail of large orders.
11.7%
Overall Return Rate
Return propensity varies materially by product category — see Customer Value for the full breakdown.
85.4%
Repeat Customer Rate
Share of sessions from customers with at least one prior order, by the dataset's rule-based segment definition.

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

Data & Analytics (Python)
pandas, numpy, scipy for generation and analysis
9 reusable analytics modules, no inline math in the UI
60 pytest unit tests covering every module, including edge cases
33 automated dataset validation checks
One script (run_all.py) computes every number the site displays
Product (Next.js / TypeScript)
Next.js App Router, TypeScript, Tailwind CSS, shadcn/ui
Recharts-based chart components on a validated, accessible color system
TypeScript mirrors of the Python analytics for live client-side calculators
Server-side filtering API for the Data Explorer — the full dataset never reaches the browser
Every chart-bearing section follows Business Question → Metric → Observation → Interpretation → Caveat

Statistics & Probability Covered

Descriptive statistics (mean, median, mode, percentiles, IQR, outliers)Categorical & numerical association, covariance, correlation, fitted linesSet-theoretic probability (union, intersection, complement, conditional)Bayes' theoremEmpirical independence checksPermutations, combinations, counting principlesDiscrete random variables: PMF, CDF, expectation, variance, SDBernoulli & Binomial distributionsHypergeometric distribution (sampling without replacement)Uniform, Triangular & Exponential continuous distributions

Skills Demonstrated

Business Analytics
Product Analytics
Statistics
Probability
Data Visualization
Python (pandas, numpy, scipy)
SQL-style analytical thinking (filtering, grouping, aggregation)
Data Storytelling
Decision Making

Interactive Demo

The whole point of CommerceLens is that it’s not a static report — try it directly: