Linear regression
Learn least squares, assumptions and model diagnostics.
Predict a continuous target and inspect residuals on unseen data.
Interview questions
Choose a question to reveal its answer.
01EasyCoreHow do you interpret a linear regression coefficient?
Answer
How do you interpret a linear regression coefficient?
Change in predicted response for a one-unit feature increase holding other features fixed.
Interpret the coefficient of floor area in a house-price model.
02EasyCoreWhat is the role of the intercept in linear regression?
Answer
What is the role of the intercept in linear regression?
Predicted response when all features are zero.
Read the baseline output of a fitted line.
03EasyCoreWhat is a residual, and how is it calculated?
Answer
What is a residual, and how is it calculated?
Observed response minus predicted response.
Calculate the signed error for a single house prediction.
04MediumHigh priorityVisualHow does ordinary least squares estimate coefficients?
Answer
How does ordinary least squares estimate coefficients?
Chooses coefficients that minimize the sum of squared residuals.
For a model ŷ = Xβ, the objective is to minimize ||y − Xβ||². With full column rank, the normal equations have a unique coefficient solution; numerical implementations typically prefer QR or SVD to explicitly inverting XᵀX. Linear regression does not require normally distributed inputs, although classical inferential assumptions matter for standard errors.
Fit a line by penalizing large errors quadratically.
from sklearn.linear_model import LinearRegression
X = [[1], [2], [3]]
y = [2, 4, 6]
m = LinearRegression().fit(X, y)
print(m.predict([[4]])) # [8.]A minimal linear regression illustration; real evaluation needs held-out data.
05MediumHigh priorityWhy does MSE penalize large errors more strongly?
Answer
Why does MSE penalize large errors more strongly?
Average squared prediction error.
Compare continuous prediction models with larger errors penalized heavily.
06MediumCan R-squared be negative?
Answer
Can R-squared be negative?
One minus residual sum of squares divided by total sum of squares; may be negative on test data.
R² = 1 − SSE/SST when SST is nonzero. A negative held-out R² means the model's squared error exceeds the reference based on the observed evaluation-target mean. It does not necessarily mean the model has a negative correlation with the target.
Compare prediction performance against a mean baseline.
07MediumWhat is homoscedasticity and how do you diagnose violations?
Answer
What is homoscedasticity and how do you diagnose violations?
Conditional error variance is constant across predictor values.
Inspect a residual plot for a funnel shape.
08MediumHow does multicollinearity affect regression coefficients?
Answer
How does multicollinearity affect regression coefficients?
Strong linear dependence among predictors can destabilize coefficient estimates.
Include both centimeters and meters as separate features.
09HardWhen would you use Ridge regression?
Answer
When would you use Ridge regression?
Adds an L2 coefficient penalty to the squared error objective.
Shrink coefficients when predictors are correlated.
10HardWhy can Lasso produce sparse coefficients?
Answer
Why can Lasso produce sparse coefficients?
Adds an L1 coefficient penalty and can set coefficients to zero.
Select a sparse set of predictors.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. Actual target is 12 and predicted target is 9. What is the residual?
2. What is the MSE for prediction errors -2 and 4?
3. What may happen when two predictors are nearly identical?
Classification algorithms
Continue to the next set of interview questions.