Answers for "how to find the correlation in a data set using python"

2

correlation analysis of dataframe python

import seaborn as sns
#load the dataset
df = sns.load_dataset('iris')
#calculate correlation
corr_matrix = df.corr('pearson') #kind of correlation->  ‘pearson’, ‘kendall’, ‘spearman’
#plot correlation
corr_matrix.style.background_gradient(cmap='coolwarm')
# 'RdBu_r', 'BrBG_r', & PuOr_r are other good diverging colormaps
Posted by: Guest on August-31-2021
0

how to find correlation in scipy?

>>> xy = np.array([[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
...                [2, 1, 4, 5, 8, 12, 18, 25, 96, 48]])
>>> scipy.stats.linregress(xy)
LinregressResult(slope=7.4363636363636365, intercept=-85.92727272727274, rvalue=0.7586402890911869, pvalue=0.010964341301680825, stderr=2.257878767543913)
Posted by: Guest on June-19-2021

Code answers related to "how to find the correlation in a data set using python"

Python Answers by Framework

Browse Popular Code Answers by Language