Correlation Heatmaps

A correlation heatmap is graphical representation using color gradients to show a relationship between variables. The values are represented in colors in a gradient. The stronger the color between two variables, the more correlation there is. Whereas, the lighter the gradient,

Correlation is between -1 and 1. In addition to colors, the variables are given values. The closer it is to 1, there is a direct relation. The closer to -1, there is more of an inverse relationship.

“This analysis is one of the methods used to decide which features affect the target variable the most, and in turn, get used in predicting this target variable. In other words, it’s a commonly-used method for feature selection in machine learning.”

A correlation heatmap can be done with Seaborn. The following is what I did to see which variables below correlated with cardiovascular disease.


sns.heatmap(df.corr(), annot = True, vmin=-1, vmax=1, center= 0, cmap= ‘coolwarm’, linewidths=3, linecolor=’blue’)

What is fun with these is that you can change the color options to your liking. These are such a great tool for your correlation analysis! Definitely worth trying out for your analysis projects!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store