Jump to content

Wai Yin Mok

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Wai Yin Mok

  1. 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

×
×
  • Create New...