Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Tune L1 vs L2 for Ads

MediumMachine Learning00:00
Practice interviewer
In session
5 left
00:00

Your question is Tune L1 vs L2 for Ads. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Business Context

Meta Ads ranking models use high-dimensional behavioral and campaign features to predict whether a user will click an ad impression. A simple linear baseline is still valuable in production because it is fast, stable, and easy to debug, but it can overfit badly when feature space is wide and sparse. Your task is to compare L1 and L2 regularization in a click-through-rate classification setting and explain when each is preferable.

Dataset

You are given a training table built from one week of ad impression logs.

Feature GroupCountExamples
Dense numerical18historical_ctr, advertiser_spend_7d, user_session_depth, page_load_ms
One-hot categorical420device_type, country, placement, campaign_objective, app_surface
Sparse hashed text/context560query intent bucket, ad text n-gram hashes, landing page topic hashes
Temporal6hour_of_day, day_of_week, recency_since_last_click
  • Rows: 1.2M ad impressions
  • Features: 1,004 engineered features after encoding
  • Target: clicked = 1 if the impression received a click, else 0
  • Class balance: 6.4% positive, 93.6% negative
  • Missing data: ~8% missing in some advertiser quality features and ~3% missing in user activity recency fields

Success Criteria

A strong solution should:

  • improve generalization versus an unregularized logistic regression baseline,
  • compare L1 and L2 using cross-validated model selection,
  • explain the impact on sparsity, stability, and interpretability,
  • achieve log loss < 0.23 and AUC-ROC > 0.78 on the holdout set.

Constraints

  • Inference must stay under 10 ms per request for a linear model in Meta Ads serving.
  • The model should remain interpretable enough to inspect top weighted features.
  • Training should fit on a single production training job without expensive feature selection passes.

Deliverables

  1. Train logistic regression baselines with no regularization, L1, and L2 penalties.
  2. Use cross-validation to tune regularization strength and select the best model.
  3. Compare coefficient sparsity, validation performance, and holdout performance.
  4. Explain what regularization is and when L1 should be preferred over L2, and vice versa.
  5. Provide a production recommendation for Meta Ads ranking.