Answers for "find correlation in python"

0

python calculate correlation

# For a measure the strength of association between two variables;
import numpy as np
from scipy.stats import spearmanr, pearsonr, kendalltau
serie1 = np.array([-2, -1, 0, 1, 4])
serie2 = np.array([-2.5, -.75, 1, 2, 6])
 
# linear ==> Pearson
pearsonr(serie1, serie2)
pearsonrResult(correlation=0.9964803994464919, pvalue=0.0002505212149642603)

# Non-linear ==> Spearman or kendall 
spearmanr(serie1, serie2)
SpearmanrResult(correlation=0.9999999999999999, pvalue=1.4042654220543672e-24)
kendalltau(serie1, serie2)
KendalltauResult(correlation=0.9999999999999999, pvalue=0.016666666666666666)
Posted by: Guest on August-06-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 "find correlation in python"

Python Answers by Framework

Browse Popular Code Answers by Language