Skip to main content
Module 3 · Lesson 4 of 513/56 in the course~18 min
Module lessons (4/5)

Linear regression with scikit-learn

Lesson preview5 hands-on exercises readyMachine Learning: from first principles to practice · Module 3 — Linear regression and gradient descent

The fit, predict and score pattern, coefficients and the R-squared score.

What you'll learn in this lesson

  • Fit and use a scikit-learn model with fit, predict and score.
  • Read the learned coef_ and intercept_.
  • Know that scikit-learn expects a 2-D X.

Overview

You have now solved linear regression two ways by hand. scikit-learn wraps the same maths in a consistent interface that every model in the library shares:

Move the outlier shift slider below to see how one large residual changes MAE, RMSE, and R² live.

Sections covered in this lesson

  1. 1The hook: the same idea, industrial strength
  2. 2The estimator pattern
  3. 3Interactive lab: inspecting R², MAE and RMSE
  4. 4scikit-learn estimator method map
  5. 5The R² score
  6. 6Practice
Pro Lesson · Module 3 — Linear regression and gradient descent

Unlock "Linear regression with scikit-learn" and the full Machine Learning: from first principles to practice curriculum

The fit, predict and score pattern, coefficients and the R-squared score.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Machine Learning: from first principles to practice plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.