Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📈 Cohort Retention Analysis

An end-to-end cohort retention analysis pipeline for a B2B SaaS subscription product. Analyzes 10,000 users over 2 years using both weekly and monthly cohorts, measuring user retention and Net Revenue Retention (NRR) — the two most critical metrics for SaaS product health and investor reporting.


🎯 Business Questions

  • What percentage of users are still active after 1, 3, and 6 months?
  • Is cohort quality improving over time (is the product getting better)?
  • What is our Net Revenue Retention — are existing customers growing or shrinking in value?
  • When is monthly vs weekly cohort analysis the right tool?

📁 Project Structure

cohort_retention_analysis/
├── outputs/                     # Charts, cohort tables (CSV), executive summary
├── src/
│   ├── data_prep.py             # 2 years of synthetic SaaS subscription events
│   ├── cohorts.py               # Monthly + weekly cohort table construction
│   ├── retention.py             # Retention curves, churn rates, NRR
│   └── visualizations.py       # Heatmaps, curves, dashboard
├── main.py                      # Run the full pipeline
├── requirements.txt
└── README.md

📊 Data

Synthetic SaaS subscription data simulating realistic behavior:

Parameter Value
Users 10,000
Period Jan 2023 – Dec 2024
Plans Starter ($29), Professional ($49), Enterprise ($149)
Month 1 churn ~25% (industry benchmark)
Steady-state churn ~3%/month
Expansion probability 15% of retained users upgrade
Cohort quality Improves 0.5%/month (product improving)

📐 Methodology

Cohort Construction

Frequency Best For
Weekly Evaluating product releases, short-term A/B tests, operational decisions
Monthly Strategic planning, investor reporting, long-term trend analysis

Retention Metrics

User Retention Rate

Retention(cohort, period) = Active users in period N / Users at signup

Net Revenue Retention (NRR)

NRR = (Starting MRR - Churned MRR + Expansion MRR) / Starting MRR
  • NRR > 110%: World-class (Snowflake, Twilio tier)
  • NRR > 100%: Healthy — revenue grows even without new customers
  • NRR < 100%: Revenue leaking — must be addressed

Churn Analysis

  • Monthly churn rate with 3-month rolling average
  • Annualized churn = 1 - (1 - monthly_churn)^12
  • Cohort quality comparison at Month 1, 3, 6, and 12

📈 Output Files

File Description
01_monthly_retention_heatmap.png Classic cohort heatmap (monthly)
02_weekly_retention_heatmap.png Weekly granularity heatmap
03_retention_curves.png Avg retention curve + individual cohorts
04_nrr_over_time.png Net Revenue Retention trend
05_churn_rate.png Monthly and annualized churn over time
06_cohort_quality.png Retention improvement across cohorts
07_summary_dashboard.png Full summary dashboard
monthly_user_retention.csv Monthly cohort table (exportable)
monthly_mrr_retention.csv Monthly MRR retention table
weekly_user_retention.csv Weekly cohort table
retention_executive_summary.txt Business-ready summary

🚀 Getting Started

git clone https://github.com/yourusername/cohort_retention_analysis.git
cd cohort_retention_analysis
pip install -r requirements.txt
python main.py

No data download required — data is generated synthetically with realistic SaaS benchmarks.


🛠 Tech Stack

  • Python 3.14+
  • pandas — cohort table construction and time-series manipulation
  • numpy — simulation and statistical computation
  • matplotlib — heatmaps, curves, and dashboards
  • scipy — statistical analysis

💡 Key Concepts Demonstrated

  • Weekly vs monthly cohort construction from event data
  • User retention and revenue retention (NRR) analysis
  • Cohort heatmap visualization (most-recognized product analytics chart)
  • Churn rate calculation (monthly and annualized)
  • Cohort quality trend analysis
  • Net Revenue Retention with expansion modeling
  • SaaS subscription event simulation

👤 Author

Built as part of a data science / product analytics portfolio project.
Background: 15+ years in Marketing Analytics | SQL | Python | Statistical Modeling

About

This model Generates 2 years of synthetic user subscription and revenue event data for cohort retention analysis. It builds weekly and monthly cohort tables from subscription event data then computes retention curves, churn rates, and Net Revenue Retention (NRR) from the cohort tables.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages