Single logo
  • Courses
  • Blog
  • About
Join for freeJoin free
  1. Blog
  2. /
  3. Learning paths
  4. /
  5. Predict a Number: Regression from Scratch to Regularisation

Learning path · 6 tutorials

Predict a Number: Regression from Scratch to Regularisation

Who it is for
Learners who can prepare data with scikit-learn and want to build and judge their first regression models.
What you will achieve
Understand the line and its cost, watch gradient descent find it, fit linear regression in scikit-learn, score it with MAE, RMSE and R-squared, spot overfitting, and tame it with Ridge and Lasso.
Prerequisites
Basic Python and pandas · Train-test split and scikit-learn Pipelines
Start with step 1: Linear Regression and the Cost Function

Curriculum

  1. 1
    Step 1: Linear Regression and the Cost Function: Draw a Line, Score It

    Draw a straight line through six kids' ages and weights, measure every miss, and turn the misses into one score, the mean squared error. Then let np.polyfit find the line with the lowest score.

  2. 2
    Step 2: Gradient Descent Explained: Feel the Slope, Step Downhill

    Instead of handing over the best line, let the computer walk to it: measure the slope of the cost, step downhill with a learning rate, repeat. Shown step by step on six kids' ages and weights.

  3. 3
    Step 3: Linear Regression in scikit-learn: Fit, Predict and Read the Price Tags

    Predict a yearly medical bill with scikit-learn's LinearRegression: first from age alone, then from every column inside a pipeline. Each coefficient reads like a price tag, and smoker_yes is by far the biggest.

  4. 4
    Step 4: Regression Metrics: MAE, RMSE, R-squared and the Baseline to Beat

    Score a regression model honestly: MAE, MSE and RMSE from four darts, then the insurance model on 268 test people, a DummyRegressor baseline to beat, R-squared and adjusted R-squared, and a residual plot.

  5. 5
    Step 5: Polynomial Regression, Overfitting and Underfitting: Bend the Line, Watch the Test Score

    Give a linear model extra columns with PolynomialFeatures and it can bend. Then watch train and test scores split apart: degrees 1, 2 and 16 on Canada's income per person, and degrees 1 to 5 on the insurance model.

  6. 6
    Step 6: Regularisation with Ridge and Lasso: Put a Price on Big Weights

    The degree-4 insurance model overfits (train 0.876, test 0.754). Ridge shrinks every weight and lifts the test score to 0.843; Lasso switches off all but 40 of 495 columns and reaches 0.862.

Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.