WeCodeAcademy

Regression and R-squared

Regression fits a line to describe how one number depends on another. scipy.stats.linregress returns the slope, the intercept, the correlation r and a p-value for the slope. R squared (r ** 2) is the share of the variation in y that the line explains.

Examplepython
Open in editor »
Quick check

An R squared of 0.9 means the line explains...

Your turn: write the code

Fit the line and print the slope rounded to 2 decimals.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.