✳ BETWEEN QUESTIONS ML STUDY ATLAS

A QUESTION-LED LESSON

Linear Regression: Predicting a Number from Data

Classification chooses a class. Regression predicts a numerical value: for example, a trip duration or a temperature.

The model is a family of lines

With one feature, a linear regression model predicts ŷ = wx + b. The slope w describes how the prediction changes as x increases by one unit, holding other inputs fixed. The intercept b is the predicted value at x = 0; it is not necessarily meaningful outside the observed range.

Fit the parameters

For examples (xᵢ, yᵢ), one common objective is mean squared error: MSE = (1/n) Σ(ŷᵢ − yᵢ)². Squaring makes large residuals count more. Minimizing training MSE chooses parameters that fit the training data under that objective. First make the line miss a point, then move it closer. Each vertical segment shows prediction minus observation; its square contributes to the average.

INTERACTIVE EXPLORATION

Fit a line and watch its errors

Adjust slope and intercept for three fixed examples. Each vertical segment is a residual; the readout averages their squared lengths.

A line is a choice, not a guarantee

A fitted line need not describe the true relationship well, and extrapolation can fail. A statistical linear regression problem can sometimes be solved in closed form; gradient descent is one possible optimization method, not a requirement.

Check your understanding

For y = 5 and ŷ = 3, what is the squared error?

(3 − 5)² = 4. Mean squared error averages such values over examples.

Keep exploring

Features and labels ↗What is a loss? ↗How can we reduce loss? ↗

Further reading

Source and further reading ↗