Quick Correlation Plot with Seaborn

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:

 

Leave a Reply

Your email address will not be published. Required fields are marked *