Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 04 / Topic 2 of 6

Linear regression

Linear regression fits a line: y ≈ w·x + b. The loss is mean squared error (MSE) — average of squared differences. Squaring punishes big misses and makes the maths smooth.

For a line, calculus gives a closed-form solution (np.linalg.lstsq): the exact best w and b. That is rare luxury — most models have no formula — but it makes linear regression the perfect test bed: we can run gradient descent and check it against the truth.

Done here? The practice set for Part 4 — 4 exercises with solutions — is on the part page.

Search the guide