Skip to content
  • Home
  • How To
  • M0
  • M1
  • Agents
  • M2
  • Module 3 - Classical ML
  • M4
  • M5
  • M6
  • Progress
  • Contact
  • Pricing
  • Sign in
  • Future
  1. Module 3M3
  2. ›
    S1What a Model Is, and What Fitting Means
  3. ›
    Intro
  4. ›
    S1›Intro
  1. Module 3
  2. ›
  3. Section 1

Section 3.1: What a Model Is, and What Fitting Means

A model takes a listing's features and returns a number, and the numbers inside it, its parameters, decide which number. Fitting chooses those parameters from listings whose price is already known, by making a loss, one number that scores the predictions against the known prices, as small as it can. Every lesson in this section fits scikit-learn's LinearRegression, the least squares fit Lesson 2.3.4 computed with NumPy. The section covers installing scikit-learn and the interface its models share, holding listings back from the fit, the loss a fit minimizes, and the metrics and residuals that say how far off the predictions are.

Lesson 2.3.4 left a warning in its Assignment: a smaller sum on the listings a model was fitted to says nothing yet about new listings. This section turns that warning into a rule, that a score says how a model does on new listings only when it comes from rows the fit never saw. The quiet failures start here too, a fill computed before the split that has already seen the test rows, a squared error read as if it were money, an R² compared across two different sets of rows, and none of them raises an error.

Lessons

  1. Installing scikit-learn, and What a Model Actually Is - scikit-learn installed, a model as a function with learned parameters, scikit-learn's fit and predict, LinearRegression shown to be 2.3.4's least squares, and predictions for listings the fit never saw.
  2. The Split, and What a Held-Out Set Is For - why a training score lies, train_test_split, what a held-out row must be, a split stratified on price bands so each band keeps its share on both sides, and one split as one draw.
  3. Loss Functions - What You Are Actually Minimizing - what a loss is, squared error and why the mean wins it, absolute error and why the median wins it, two losses fitting two different lines to the same listings, and the loss you minimize against the number you report.
  4. Regression Metrics and Reading a Residual - residuals, MAE, MSE and RMSE (mean absolute error, mean squared error and its square root), R² against a baseline, residual plots, and choosing the metric that matches the question.

By the end you will be able to:

  • Install scikit-learn into (bootcamp), fit LinearRegression on a listing's area, show that its slope and intercept are the least squares fit np.linalg.lstsq computes, and predict for listings it never saw.
  • Split listings into training and test rows reproducibly, stratify the split on price bands, and state what a held-out row must be.
  • Find the constant each loss prefers by scanning, and say which loss LinearRegression minimizes and why.
  • Score predictions with MAE, RMSE and R² against a baseline, and read a residual plot for the failure the headline number hides.
Your progress
Current streak
🔥 0
Lessons marked today
0 / 3
Longest streak
0

Sign in

The bootcamp

  • Curriculum
  • How To
  • Pricing
  • Changelog
  • Future

The community

  • Discord
  • Reviews
  • Contact

Follow

  • Instagram
  • X
  • TikTok
  • Reddit

Legal

  • Terms
  • Privacy
  • Refunds

Coming soon on November 16, 2026

The AI/ML Newsletter, free.

SubscribeComing soon on December 1, 2026

Confirm by email, unsubscribe in one click.

Theme