/example-app-cohort-analysis

Primary LanguagePythonApache License 2.0Apache-2.0

👥 Cohort Analysis App

Streamlit App

This Cohort Analysis App calculates the retention rate (the percentage of active customers compared to the total number of customers, split by month). This retention rate is then visualized and interpreted through a heatmap.

These 2 demos are based on the following tutorials:


First app (Bikes dataset)

This demo is inspired by this Cohort Analysis Tutorial.

This dataset came from the hypothetical Sprocket Central Pty Ltd, a medium size bikes & cycling accessories organisation.

The data was collected from January 1, 2017 to December 31, 2017, and available in CSV format, downloadable here.

Each row in the dataset contains information about an individual bike purchase:

  • Who bought it
  • How much they paid
  • The bike's brand and product line
  • Its class and size
  • What day the purchase happened
  • The day when the product was first sold

The underlying code takes those purchases and groups them into cohorts and calculates the retention rate, split by month, so that one can answer the question:

The underlying code groups those purchases into cohorts and calculates the retention rate (split by month) so that one can answer the question:

if I'm making weekly changes to my store to get people to come back and buy more bikes, are those changes working?"

These cohorts are then visualized and interpreted through a heatmap powered by Plotly.


Second app (Food dataset)

This demo is inspired by this Cohort Analysis Tutorial

This dataset comes from the hypothetical Relay Food company. The data spans from June 1, 2009 to September 3, 2010 and is available in CSV format (downloadable here).

Each row in the dataset contains information about an individual food order:

  • Who bought it
  • How much they paid
  • The pick-up date

The underlying code groups those purchases into monthly cohorts (with the user's cohort group based on their first order) and calculates the retention rate so that one can answer the question:

if I'm making monthly changes to my shop to get people to come back and order more, are those changes working?"

These cohorts are then visualized and interpreted through a heatmap powered by Plotly.


Process

Here are the steps we undertook to create the cohort analysis app:

  1. Load the data
  2. Create the cohort
  3. Calculate the retention rate
  4. Visualize and interpret the retention rate via the heatmap

About the app


Questions? Comments?

Please ask in the Streamlit community.