Build Point-in-Time Churn Labels for a Messenger Churn Model
Last updated: November 29, 2026
Quick Overview
Write pandas code that turns daily Messenger activity into training rows for a churn model: for each weekly snapshot date, every user active in the prior 28 days gets features from that window only and a label of 1 if they have no activity in the next 28 days, skipping snapshots whose label window is not fully observed.
Meta
November 29, 20260
0
0 solved
Write pandas code that turns daily Messenger activity into training rows for a churn model: for each weekly snapshot date, every user active in the prior 28 days gets features from that window only and a label of 1 if they have no activity in the next 28 days, skipping snapshots whose label window is not fully observed.
Messenger's re-engagement models need labels that do not leak future information into features, and Meta MLE interviews often include a data-preparation round where the model itself matters less than the training data. The interviewer checks strict time boundaries, eligibility, censoring of recent snapshots and that each row is a (user, snapshot) pair.
What the Interviewer Expects
- Use half-open windows so the snapshot day belongs to the future
- Compute features only from data before the snapshot
- Restrict eligibility to users active in the lookback
- Drop snapshots whose label horizon extends past the data
- Return one row per user per snapshot
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you split these rows into train and validation without leakage?
- How would you handle users who appear in many snapshots?
- What features would you add, and which ones could leak?
- How would you scale this to billions of user-days?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
activity(user_id, ds, messages_sent) with one row per active user-day. Snapshots are dates such as every Monday. Lookback window is [s - 28, s), label window [s, s + 28). Users not active in the...
Approach
Loop over snapshots (there are few). For each, slice past and future windows, aggregate features per user from the past slice only, and label by set membership in the future slice. Skip a snapshot if ...