WeCodeAcademy

Linear Regression

Linear regression draws the straight line that best fits the points. The line is y = coef * x + intercept. After fit, the numbers it found are stored in coef_ (the slope, one per feature) and intercept_. Because the names end in an underscore, you can tell they were learned from data.

Examplepython
Open in editor »
Quick check

In `y = coef * x + intercept`, what does the intercept tell you?

Your turn: write the code

Fit a line to hours studied against marks and print the slope (coef_) 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.