Regularization and generalization
Understand model complexity, bias, variance and train-test separation.
Tune regularization with validation data and inspect learning curves.
Interview questions
Choose a question to reveal its answer.
01EasyCoreWhat is statistical bias in model estimation?
Answer
What is statistical bias in model estimation?
Systematic error of an estimator relative to a target under repeated sampling.
A rigid linear model misses a nonlinear pattern consistently.
from sklearn.linear_model import Ridge, Lasso
ridge = Ridge(alpha=1.0)
lasso = Lasso(alpha=0.1)
# Compare with cross-validation on training data.The penalties differ; alpha values are not directly comparable across objectives.
02EasyCoreWhy does model variance affect generalization?
Answer
Why does model variance affect generalization?
Sensitivity of fitted predictions to changes in training data.
A deep tree changes dramatically after a few examples are replaced.
03EasyCoreHow does L1 regularization encourage sparsity?
Answer
How does L1 regularization encourage sparsity?
Adds a term proportional to the sum of absolute coefficients.
The L1 objective adds λΣ|wᵢ| to the fitting loss. The nondifferentiable point at zero helps produce exact zero weights in many optimization solutions, unlike ordinary L2 shrinkage. Tune λ using validation data.
Encourage a sparse linear model.
04MediumHigh priorityHow does L2 regularization affect weights?
Answer
How does L2 regularization affect weights?
Adds a term proportional to the sum of squared coefficients.
The L2 penalty adds a term proportional to λΣwᵢ², encouraging smaller weights. It can stabilize correlated predictors and reduce model variance but introduces bias. Avoid treating penalty strength as universally comparable across libraries.
Shrink large coefficients without generally forcing exact zeros.
05MediumHigh priorityWhen would you use elastic net?
Answer
When would you use elastic net?
Combines L1 and L2 coefficient penalties.
Select features while retaining stability among correlated predictors.
06MediumVisualHow does early stopping prevent overtraining?
Answer
How does early stopping prevent overtraining?
Stops iterative training using validation performance or another stopping criterion.
Keep the checkpoint before validation loss starts deteriorating.
07MediumHow do you interpret learning curves?
Answer
How do you interpret learning curves?
Plots performance as a function of training set size or training progress, with axes stated.
Inspect whether more training examples may reduce the train-validation gap.
08MediumWhat is the difference between a parameter and a hyperparameter?
Answer
What is the difference between a parameter and a hyperparameter?
Setting chosen outside the fitted model parameter optimization.
Select a tree's maximum depth before fitting.
09HardWhy use nested cross-validation?
Answer
Why use nested cross-validation?
Uses inner folds for tuning and outer folds for evaluation.
Estimate performance after hyperparameter selection without optimistic reuse of validation folds.
10HardWhy keep a test set separate from model selection?
Answer
Why keep a test set separate from model selection?
Held-out data reserved for final evaluation and not routine model selection.
Measure performance only after choosing the final configuration.
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. Which penalty commonly produces exact zero coefficients in linear models?
2. A model has poor training and validation performance. What should be investigated?
3. Which procedure estimates performance while accounting for hyperparameter tuning?
Machine learning fundamentals
Continue to the next set of interview questions.