Jump to content

Professor of Information Systems


Wai Yin Mok

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

Link to comment
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.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...