L1 Versus L2 Regularization for Sparse Diagnosis Code Features

Last updated: November 29, 2026

Quick Overview

You are fitting a logistic regression to predict Type 2 diabetes onset from about 40,000 one-hot ICD-10 and procedure code features on 200,000 Aetna members. Explain how you would choose between L1, L2 and elastic net regularization and how you would tune it.

CVS Health
Machine Learning
Data Scientist
CVS Health
November 29, 2026
Data Scientist
Technical Screen
Machine Learning
Medium

0

0

0 solved


You are fitting a logistic regression to predict Type 2 diabetes onset from about 40,000 one-hot ICD-10 and procedure code features on 200,000 Aetna members. Explain how you would choose between L1, L2 and elastic net regularization and how you would tune it.

Claims-based risk models at Aetna often have far more sparse code features than are informative, and clinicians want a short list of drivers. The interviewer is testing understanding of overfitting, the geometry of penalties and practical tuning.

What the Interviewer Expects
  • Explains why the unregularized model overfits here
  • Contrasts L1 sparsity with L2 shrinkage
  • Recognizes correlated codes make L1 unstable and motivates elastic net
  • Tunes lambda with cross validation grouped by member and split by time
  • Mentions feature scaling and the intercept not being penalized
Key Topics to Cover
L1 lasso
L2 ridge
elastic net
overfitting
cross validation
sparse features
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
  • Clinicians see a selected code flip in and out across retrains. Why, and what do you do?
  • How would you group codes hierarchically to reduce dimension?
  • How does regularization interact with class imbalance here?
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

Positives are perhaps 3% of members, features are binary and very sparse, and many codes are near-duplicates (E11.9 and E11.65, or a code and its procedure). Goals: good out of sample discrimination a...

Approach

Penalized objective: min⁡β  −1n∑i[yilog⁡pi+(1−yi)log⁡(1−pi)]+λ(α∥β∥1+1−α2∥β∥22)\min_\beta \; -\frac{1}{n}\sum_i \big[y_i \log p_i + (1-y_i)\log(1-p_i)\big] + \lambda\Big(\alpha\|\beta\|_1 + \tfrac{1-\alpha}{2}\|\beta\|_2^2\Big) α=1\alpha = 1 is lasso, $\a...


Submit Your Answer
Markdown supported

Related Questions