Unreliable Engagement Counter in a Filing-Completion Model
Machine LearningModel answerLast updated
Diagnose a cumulative usage feature with many zeros and nulls, handle its absence at scoring time, and explain why it correlates negatively with completing a tax return.
Context
Your team is building a classifier that predicts whether a user will complete their tax return in a consumer tax-filing product. The binary label is success.
One feature looks very strong in offline experiments:
session_count: the cumulative number of sessions the user has had in the product.
You notice three problems:
- In the training table,
session_countis 0 for a large share of rows and missing for another large share. - Engineering says the field is not available when the model needs to score a user, even though it exists in the schema.
- In exploratory analysis,
session_countis negatively correlated withsuccess, which surprises the team.
You have access, in principle, to raw product event logs (page views, step completions, timestamps), but instrumentation is known to be imperfect.
What to answer
- Zeros and missing values. How would you find out why
session_countis so often 0 or missing, and how would you handle each case when modeling? - Feature unavailable at scoring time. What are your options? How do you choose between (a) dropping the feature, (b) building a proxy that can be computed at scoring time, and (c) changing when the prediction is made or how the problem is defined?
- Negative correlation. Give at least two plausible explanations, including one that takes the opposite view of the obvious story. For each, say what extra data or analysis would confirm or reject it.
Your answer should explicitly address leakage risk, feature availability, and how you would explain the trade-offs to non-technical stakeholders.
Hints
Hint 1
A 0 and a NULL are not the same thing. Ask what upstream process produces each one, then slice both by platform, app version, date, and identity type to look for patterns.
Hint 2
A cumulative count only makes sense relative to a point in time. Ask when it was snapshotted compared with the moment you would actually make the prediction, and whether it includes sessions after the user finished filing.
Hint 3
To decide between dropping, proxying, or retiming, compare three models on a time-based split: no feature, an as-of-time version, and the raw cumulative version used only as a leakage check. For the negative correlation, consider both 'struggling users return more' and 'finishers stop returning'.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Overview
The core idea is that a feature is only useful if it is correct, computed as of the prediction time, and obtainable at serving time. A cumulative counter is a classic place for all three to fail. Verify claims with data, and avoid reading a correlation as a causal story.
1. Investigating zeros and missing values
Separate the two states. Agree on semantics with the data owners:
0could be a real "no sessions," an ETL default fill, or a counter that was never incremented.NULLcould be a failed join, a user absent from the sessions table, a cohort the feature was never computed for, or logging that had not shipped yet.
Profile both by likely causes:
- Platform and app version (one client may not emit session events).
- Calendar time (a step change suggests an instrumentation or pipeline deploy).
- Identity: anonymous vs. logged-in, cross-device users, accounts migrated from prior years (ID mismatches break joins).
- User type: new vs. returning, assisted vs. self-serve.
- The label: if missingness predicts
success, it is not missing completely at random.
Reconstruct from raw events. Recompute sessions from page views and step completions and compare with the stored value. Users with events but a stored 0 point to a pipeline bug. Users with no events may be truly inactive or may use an uninstrumented surface.
Check point-in-time correctness. If the counter was snapshotted at the end of the season, it includes sessions after the prediction moment, possibly after filing. Rebuild it as "sessions up to time t."
Treatment, once the mechanism is known:
| Cause | Action |
|---|---|
| Pipeline bug | Fix upstream or backfill from logs; do not model around it |
| Genuine zero | Keep as 0 |
| Informative missingness | Keep NULL distinct; add an is_missing flag or use a model that handles NULLs natively (e.g., gradient-boosted trees) |
| Missingness only in training data construction | Fix the training set, since the pattern will not exist in production |
Never silently impute NULL as 0; it merges two different populations. Validate with a time-based split and report metrics on the missing and non-missing slices separately.
2. Feature not available at scoring time
Verify the claim first. "Unavailable" can mean:
- No online source exists at all.
- Only a nightly batch exists (stale by up to a day).
- It is computable but would need a streaming counter.
- It is a post-hoc aggregate that only exists after the outcome.
Each leads to a different fix.
Options
| Option | Right when | Cost |
|---|---|---|
| (a) Drop | No point-in-time version is feasible, or lift is small | Lower but honest offline metrics |
| (b) Proxy | Something similar is computable at scoring time | Must be built identically offline and online |
| (c) Retime or redefine | The signal only matures later, or the action can wait | Shorter window to intervene |
Candidate proxies: sessions so far as of t from a real-time counter; steps completed in the current session; time since account creation; prior-year behavior; the lagged batch value plus the lag itself.
Candidate redefinitions: score at a fixed milestone (after the 2nd session, day 3 after signup); score at every session so the feature is naturally "sessions so far"; or model the probability of completing within the next k days given the state at t.
Decision procedure. Using the same time-based split, train:
- A model without the feature.
- A model with the as-of-t version or proxy.
- A model with the raw cumulative feature, purely as a leakage diagnostic.
If (3) is far above (2), most of the apparent power was leakage, so drop the raw feature. If (2) clearly beats (1), weigh the lift against the cost of serving it online. Ultimately tie the choice to the business action: what the score triggers (help prompt, expert offer, reminder email) and when it must fire to matter. A perfect prediction that arrives after the user has abandoned is worthless.
Communicating with stakeholders
- State plainly that the leaky offline metric is not achievable in production, and shipping on it would cause a silent drop.
- Show a lead-time vs. accuracy curve: earlier scoring means less accuracy but more time to act.
- Translate to business terms, such as incremental completions per 1,000 interventions.
- Show the engineering cost of a streaming feature next to its lift.
- Offer a recommendation, for example: ship without it now, and build the real-time counter only if the ablation shows lift above an agreed threshold.
3. Why the negative correlation?
| Explanation | Mechanism | How to test |
|---|---|---|
| Struggle / friction | Confused users or those with complex returns (self-employment, investments, rentals) need more sessions and fail more often | Stratify by return complexity (number of forms and schedules); look at error events, help views, back-navigation. Does the correlation persist within strata? |
| Window leakage / survivorship (opposite view) | Successful users finish and stop returning; unsuccessful users keep coming back until the deadline, so a full-season count inflates for failures. Here more sessions are a consequence of not succeeding, not a cause | Recompute using only pre-t sessions; count sessions after the filing timestamp. If the correlation shrinks or flips, it was an artifact |
| Instrumentation artifact | Crashes, timeouts, or a buggy client split one visit into many sessions, and the same bugs hurt completion | Examine session duration distributions, crash logs, and results by platform and version; re-sessionize consistently |
| Confounding by user type | Efficient, simple-return users complete in one or two sessions; low-intent browsers or comparison shoppers accumulate sessions without intent to file | Segment by acquisition channel, prior-year filer status, and intent signals |
A useful framing: the "obvious" story is that engagement should help. The opposite is that sessions are a symptom of difficulty or of a longer exposure window, not a driver. Only the as-of-t recomputation and stratified analysis can separate these.
Common mistakes
- Treating 0 and NULL as the same and imputing zero.
- Trusting a cumulative field without checking its snapshot time.
- Reporting the leaky offline AUC to stakeholders.
- Assuming "unavailable" means impossible rather than stale or costly.
- Interpreting the negative sign causally, or recommending that the product reduce sessions.
- Ignoring that the feature definition must be identical offline and online.