Linear and logistic regression
- ML fundamentals
- Asked often
- About 2 h 30 min to learn
- 3 vetted resources
What this topic covers
The two models every ML breadth round starts with. Linear regression fits weights by least squares, which is the maximum-likelihood fit under Gaussian noise, and its standard errors and p-values rest on assumptions about the errors; logistic regression passes a linear score through a sigmoid and is trained with log loss. Ridge, lasso and elastic-net add penalties that shrink coefficients or set some of them to zero. Interviewers check that you can write each model’s loss, explain why squared error is the wrong loss for classification, read a coefficient as a change in the prediction or in the log-odds, and say why feature scale, correlated features and confounding make coefficients misleading.
You’re ready when you can
What interviewers check, from the resources below.
- Write the linear regression equation with several features and say what each weight means
- Choose between MAE and MSE for data with outliers and justify the choice
- Explain how the sigmoid turns a linear score into a probability
- State the log loss formula and explain why logistic regression needs regularisation or early stopping
- Write the least squares, ridge and lasso objectives and say which has a closed-form solution
- Explain why lasso sets some coefficients exactly to zero while ridge only shrinks them
- Explain why least squares coefficients become unstable when features are strongly correlated
- Write the binary logistic regression loss with an L2 penalty and say what the C parameter controls
- Explain why raw coefficients can’t be compared until features are on the same scale
- Use the variability of coefficients across cross-validation folds to judge how far to trust them
Linear and logistic regression interview questions
Answer out loud, then open the points a strong answer covers. All Machine learning interview questions
What assumptions does ordinary least squares make, and what goes wrong when each one fails?
- OLS assumes the mean of the target is linear in the features and the errors are independent with constant variance; normal errors are needed only for exact intervals and p-values.
- A non-linear relationship leaves patterns in the residuals and biased predictions, while correlated or unequal-variance errors keep the coefficients unbiased but make their standard errors and p-values wrong.
- Strongly correlated features inflate coefficient variance, so individual weights swing or flip sign between samples even when predictions stay accurate; residual plots and variance inflation factors reveal both problems.
How do you interpret a logistic regression coefficient, and why train with log loss rather than squared error?
- A coefficient is the change in the log-odds of the positive class for a one-unit increase in that feature with the others held fixed, so its exponential is an odds ratio.
- Log loss is the negative Bernoulli log-likelihood and is convex in the weights, whereas squared error on a sigmoid output is non-convex and gives tiny gradients to confidently wrong predictions.
- On linearly separable data the unregularised weights grow without bound as the loss approaches zero, so add L2 regularisation or early stopping, and scale features before comparing coefficients.
What to study, in order
Each link opened and checked by hand; the date says when.
Start here
Linear regression (opens in a new tab)
Google Machine Learning Crash Course · Google for Developers · 60 min · Free · checked 26 Oct 2026
- Why
- Interviewers open the ML breadth round with linear and logistic regression and expect you to write each model’s equation, its loss and how it is trained without hesitating.
- What to read
- Read “Linear regression” (the equation and “Models with multiple features”), “Loss” and “Gradient descent”, then follow “What’s next” into the Logistic regression module and read “Calculating a probability”, “Loss and regularization” and its “Test your knowledge”.
- What to skip
- The two interactive exercises, the programming exercise and “Hyperparameters”, which the gradient descent topic already covers.
Free alternative
1.1. Linear Models (opens in a new tab)
scikit-learn User Guide · scikit-learn developers · 40 min · Free · checked 26 Oct 2026
- Why
- It gives the exact objectives for least squares, ridge, lasso, elastic-net and logistic regression, which interviewers expect you to write down and compare.
- What to read
- Read “1.1.1. Ordinary Least Squares”, “1.1.2.1. Regression” under ridge, the opening of “1.1.3. Lasso” and “1.1.5. Elastic-Net”, then “1.1.11. Logistic regression” with “1.1.11.1. Binary Case” and “1.1.11.2. Multinomial Case”.
- What to skip
- Coordinate descent, information-criteria model selection, the multi-task variants, LARS, OMP, Bayesian regression, the solver comparison, and robust and quantile regression.
Go deeper
Common pitfalls in the interpretation of coefficients of linear models (opens in a new tab)
scikit-learn documentation · scikit-learn developers · 45 min · Free · checked 26 Oct 2026
- Why
- “What does this coefficient tell you?” is a standard follow-up, and a strong answer covers feature scale, correlated features and why a fit alone can’t show causation.
- What to read
- Skim “The dataset: wages” and “The machine-learning pipeline”, then work through “Interpreting coefficients: scale matters”, “Interpreting coefficients: being cautious about causality”, “Checking the variability of the coefficients”, “The problem of correlated variables”, “Preprocessing numerical variables”, “Linear models with regularization”, “Linear models with sparse coefficients”, “Wrong causal interpretation” and “Lessons learned”.
- What to skip
- The plotting code and the dataset exploration plots; you don’t need to run the example.
Companies that test ML fundamentals most
Put Linear and logistic regression in your plan
Tell us your interview date and hours a day; it lands on the right day, in the right order.