Lesson 5 · Linear regression & coefficient interpretation

The Bedroom That Costs You Money

Lesson 1 named linear regression’s family: f(x) = w₁x₁ + w₂x₂ + ... + b, a weighted sum of the features plus an intercept. Fitting it (lesson 1’s “search” step, done here by minimizing squared error) produces one coefficient per feature — a single number that’s tempting to read as “how much this feature matters.” That reading is more dangerous than it looks.

A model predicts house price from two features: square footage and number of bedrooms. Fit on real sales data, it comes back with:

price ≈ 150 × sqft − 8,000 × bedrooms + 20,000

The bedroom coefficient is negative. Read naively, this says “each additional bedroom makes the house cheaper” — which sounds backwards; everyone “knows” more bedrooms should raise price. Nothing was miscoded and the fit isn’t broken.

The key fact a linear regression coefficient reports is narrower than “how much this feature matters”: it’s “holding every other feature in the model fixed, how much does the prediction change per unit of this one.” Square footage is in the model too. Picture two houses of the exact same 1,800 square feet — one built as a spacious 3-bedroom, one chopped into a cramped 5-bedroom. Which one is the pricier listing?

Given that picture, what does the negative bedroom coefficient actually mean?

What does the negative bedroom coefficient actually mean?