Time-Decayed Engagement Score per User with a Seven-Day Half-Life
Last updated: November 29, 2026
Quick Overview
Given daily interaction counts per user, compute an engagement score where each day's interactions decay with a seven-day half-life, both as of a chosen date and as a daily series, and rank users by score.
Meta
November 29, 20260
0
0 solved
Given daily interaction counts per user, compute an engagement score where each day's interactions decay with a seven-day half-life, both as of a chosen date and as a daily series, and rank users by score.
Feed and notification ranking at Meta use recency-weighted engagement features, and MLE screens ask candidates to build one cleanly in pandas. The interviewer checks that inactivity correctly decays the score and that the recurrence handles irregular gaps between active days.
What the Interviewer Expects
- Writes the score as a sum of actions times 0.5 to the power of age over half-life
- Computes the as-of score with vectorized weights
- Builds the daily series with the recurrence S_t = S_prev times decay(gap) plus x_t
- Handles irregular gaps without densifying
- Explains why pandas ewm (a weighted mean) is not the same as a decayed sum
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 compute this incrementally in a daily pipeline that only reads yesterday's score?
- How would you choose the half-life for a notification-ranking feature?
- How would you make the series vectorized for a billion 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
Input: user_id, ds, actions, sparse (only active days). Score definition:
A user who stops interacting should see their score hal...
Approach
As-of score: filter to days at or before the as-of date, weight each row by and sum per user. Daily series: the decayed sum satisfies , so sort b...