Choosing L1 or L2 Regularization for Sparse Trip Features

Last updated: November 29, 2026

Quick Overview

You train a logistic regression on 200k sparse one-hot trip features to predict rider cancellation. When would you choose L1, L2 or elastic net, and what does each do to the weights?

Uber
Machine Learning
Data Scientist
Uber
November 29, 2026
Data Scientist
Phone Screen
Machine Learning
Easy

0

0

0 solved


You train a logistic regression on 200k sparse one-hot trip features to predict rider cancellation. When would you choose L1, L2 or elastic net, and what does each do to the weights?

Uber data science phone screens often include a short fundamentals question before a case. This one checks that you understand the geometry and practical effect of each penalty, not just the formulas.

What the Interviewer Expects
  • State the penalized loss for L1 and L2
  • Explain why L1 produces exact zeros
  • Explain L2 behavior with correlated features
  • Recommend elastic net for many correlated sparse features
  • Mention tuning the penalty with cross validation and scaling
Key Topics to Cover
L1 regularization
L2 regularization
elastic net
sparsity
bias-variance
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • What happens to L1 when two features are perfectly correlated?
  • Why do we usually not penalize the intercept?
  • How does regularization relate to a Bayesian prior?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Ask what matters more: a small, interpretable model that ops teams can read, or best predictive accuracy. Also check whether features are correlated (city one-hot and airport flags overlap heavily)....

Approach

Penalized log loss:

L(w)=−∑i[yilog⁡pi+(1−yi)log⁡(1−pi)]+λR(w)L(w) = -\sum_i [y_i \log p_i + (1-y_i)\log(1-p_i)] + \lambda R(w)

  • L1: R(w)=∑j∣wj∣R(w) = \sum_j |w_j|
  • L2: R(w)=∑jwj2R(w) = \sum_j w_j^2
  • Elastic net: $\alpha \sum |w_j| + (1-\alpha)\sum w_j...

Submit Your Answer
Markdown supported