What is cross-validation and when should you use k-fold vs stratified k-fold?
Cross-validation evaluates model performance by splitting data into k folds, training on k-1, testing on 1, and averaging results. K-fold: use for regression and balanced classification. Stratified k-fold: maintains class distribution in each fold — use for imbalanced classification (e.g., 95% negative, 5% positive). Time series: always use TimeSeriesSplit to prevent data leakage (future data in training set).
How does gradient descent work and what are its variants?
Gradient descent minimizes loss by iteratively moving in the direction of the negative gradient. Variants: (1) Batch GD — uses entire dataset per step, slow but stable, (2) SGD — one sample per step, noisy but fast, (3) Mini-batch GD — subset per step, best of both. Modern variants: Adam (adaptive learning rates per parameter), AdamW (Adam + weight decay), RMSprop. Adam is the default choice for most deep learning and fine-tuning tasks.
What is regularization and explain L1 vs L2?
Regularization adds a penalty term to the loss function to prevent overfitting. L1 (Lasso): penalty = λ|w|, produces sparse weights (some weights become exactly 0) — good for feature selection. L2 (Ridge): penalty = λw², shrinks weights toward zero but rarely to exactly 0 — good general regularization. ElasticNet combines both. For neural networks, use dropout and weight decay (L2) instead of explicit regularization.
Know your weak spots before the interview
10-question AI readiness assessment → personalized study plan.
Take Free Assessment →Unlock 3,000+ Interview Questions
Get full access to all interview questions with detailed answers, explanations, and real company context
Unlock Full Access →