Professor of Information Systems

Recommended Posts

Hello w3schools,

I was using your site https://www.w3schools.com/python/python_ml_linear_regression.asp  to teach Linear Regression today (4/14/2020). On this web page, it says

slope, intercept, r, p, std_err = stats.linregress(x, y)

and r is the r-squared value returned from the method scipy.stats.linregress(x, y). It is not. I checked https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html about the method scipy.stats.linregress. r is the correlation coefficient of the data sets x and y, which ranges from -1 to 1. Your web page says r-squared value ranges from 0 to 1. One of your examples https://www.w3schools.com/python/trypython.asp?filename=demo_ml_r_squared contradicts this assertion. The returned value is -0.758591524376155, which is out of the range of r-squared.

In fact, r-squared = (correlation coefficient)^2. Please correct this mistake.

Thank you

Wai Yin Mok

Share on other sites

The W3Schools staff generally don't visit the forums, but they provide an email address where you can indicate problems with the site: help@w3schools.com

You can find this email address on any page by clicking the "REPORT ERROR" link at the bottom of the page.

Share on other sites

Thank you for the pointer.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.