Visualizing cohort analysis
1. Cohort analysis visualization
Welcome to the final lesson on cohort analysis. In this section, we will learn how to build powerful cohort analysis visualizations.2. Heatmap
The most effective way to visualize and analyze cohort analysis data is through a heatmap. It provides both the actual metric values, and the color coding to see the differences in the numbers visually. One of the best things about heatmaps is that they are very easy to build with Python's seaborn package.3. Load the retention table
First, we will load the retention table in a pivot format which we built in the previous lesson. It has the same format of data, with the lower right triangle filled with Not-A-Number values. This is expected as the more recent cohorts had less time to be active. You will see in the next page, that having NaN values helps producing a clean heatmap.4. Build the heatmap
Let's get down to visualizing the retention rates as a heatmap. The first step is to load the packages seaborn and pyplot. Next, we create an empty figure with pre-defined width and height in inches. We can customize this view depending on the format of the data. Then, we add a title to the table. And then we call the seaborn heatmap function. We pass the retention table to the data parameter, ensure the numbers are also printed by passing True value to the annotation argument. Then define the format as percentage with one decimal value. The vmin and vmax parameters are used to anchor the colormap and make sure the outliers don't impact the visualization. Finally, we pass the `Green` palette to the color map. You can find multiple other color palettes in seaborn documentation. We can now run the plot show function to bring the heatmap to life.5. Retention heatmap
Here we go, the retention rate heatmap that we've seen through this chapter is finally built with just a few lines of code. This visualization can be used as a standalone representation of company's retention rate, or as an analytical tool to get insights.6. Practice visualizing cohorts
Great job! Now it's your time to visualize customer cohorts metrics in a heatmap format!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.