Linear Models

Linear and logistic regression as the models everything else is compared to: coefficients, residuals, the sigmoid, and the threshold that turns a probability into a decision.

Linear Regression

ŷ = w·x + b. A weight per feature, a bias, a loss that says which mistakes hurt — and a set of assumptions the weights only make sense under.

Q · A linear model gave a coefficient of 40 minutes per kilometre and an RMSE the team liked. What did the model actually assume, and what happens when the assumptions stop being true?
Residuals & Assumptions

The residual plot is the diagnostic; the single metric is the summary. Heteroscedasticity, extrapolation and unscaled coefficients are all visible there and invisible in the RMSE.

Q · The regression metric is acceptable and the coefficients look sensible. What does a residual plot show that the metric cannot, and which of the model's assumptions does it check?
Logistic Regression
▶ lab

Linear score → sigmoid → probability, trained by gradient descent on the log loss. The threshold that turns the probability into a decision is a different step, owned by someone else.

Q · What does a logistic regression actually compute, how is it trained, and why is "the model said yes" always two decisions dressed as one?
Sigmoid & Probability

The sigmoid turns a score into a number between 0 and 1. Whether that number is a probability is a fact about calibration on the deployment distribution, not about the function.

Q · The model output is 0.8. Under what conditions does that mean 80%, and what do class weights, resampling and a changed base rate do to it?
Thresholding
▶ lab

The threshold is not part of the model. It is the point where a business decision about costs and capacity is written down, and it deserves an owner, a config and a review.

Q · Who chose 0.5, against what cost, and what happens to the business when the score distribution moves and the constant does not?
Regularized Linear Models

L1 makes weights zero, L2 makes them small, elastic net does both — and all of them penalise a feature in proportion to its scale, so the scaler is part of the model.

Q · The linear model has hundreds of features and unstable coefficients between retrains. What does a penalty on the weights do, which penalty, and why does it only mean something after scaling?