ML & Data Science Interviews · Core Algorithms · Lesson 1 of 3
Linear & logistic regression
Linear regression predicts a continuous number as a weighted sum of features, fit by minimizing squared error. Logistic regression adapts that for classification: it passes the linear score through a sigmoid to output a probability in (0,1), fit by maximizing likelihood (cross-entropy loss).
- Both are linear in the parameters, fast, and highly interpretable — a coefficient is the effect of a feature.
- Logistic regression outputs calibrated-ish probabilities and a linear decision boundary; classify by thresholding (default 0.5, but tune it).
- Key assumptions for linear regression: roughly linear relationship, independent errors, constant variance, low multicollinearity.
- They are strong baselines — always try one before reaching for something fancy.
'Regression' with 'classification'A classic gotcha: logistic regression is a classification algorithm, despite the name. It models the log-odds of the positive class as a linear function of the features.
◆ Lock it in
- Linear regression → continuous output via least squares; logistic → probability via sigmoid + cross-entropy, fit by gradient descent.
- Both are fast, interpretable, linear — excellent baselines.
- Logistic regression is classification; tune the threshold, don't assume 0.5.
Feynman drill — say it out loudExplain how logistic regression turns a linear score into a class prediction.
Step 1 rate your confidence · Step 2 pick your answer
Which statement about logistic regression is correct?
Step 1 — how sure are you?