sklearn r2_score and python stats lineregress function give very different values of R^2. Why?

Viewed 1354

I´m using the same data but different python libraries to calculate the coefficient of determination R^2. Using stats library and sklearn yield different results.

What is the reason behind this behavior?

# Using stats lineregress
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
print r_value**2

0.956590054918

# Using sklearn
from sklearn.metrics import r2_score
print r2_score(x, y)

0.603933484937

1 Answers
Related