Skip to content

Instantly share code, notes, and snippets.

@GermanCM
Last active May 31, 2019 11:34
Show Gist options
  • Save GermanCM/654334e466668d54cd99da2a3fe8b87a to your computer and use it in GitHub Desktop.
Save GermanCM/654334e466668d54cd99da2a3fe8b87a to your computer and use it in GitHub Desktop.
Pearson's correlation coefficients matrix
def get_corr_coeff(dataframe):
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
# data is the dataframe having the attributes which you want to get the correlation coeffcients from
cm = np.corrcoef(dataframe[dataframe.columns].values.T)
sns.set(font_scale=1.5)
hm = sns.heatmap(cm, cbar=True, annot=True, square=True, fmt='.2f', \
annot_kws={'size': 10}, yticklabels=dataframe.columns, xticklabels=dataframe.columns)
plt.show()
return cm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment