Quick Correlation Plot with Seaborn

Nov. 26, 2019

Read time: < 1 Minute

Correlation is the simplest way to start comparing features to see which data points may line up with other data points.

It's fairly easy to get a quick visualization with the Pandas corr() function and a fancy Seaborn plot.

The only prerequisite is that you need to make sure all the data points in your set are numerical, either by default, or design, or elimination. Once this has been accomplished, simply call the corr() function on your data set:

corr = df.corr() Then you can plot it. Feel free to change the aesthetic defaults I've included here:

plt.figure(figsize=(9,7)) sns.heatmap( corr, xticklabels=corr.columns.values, yticklabels=corr.columns.values, linecolor='white', linewidths=0.1, cmap="RdBu" ) plt.show() And you'll end up with a fancy looking plot that should resemble this:

Post navigation


You must login to comment