Last active
May 31, 2019 11:34
-
-
Save GermanCM/654334e466668d54cd99da2a3fe8b87a to your computer and use it in GitHub Desktop.
Pearson's correlation coefficients matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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