Predicting Itemizers vs Standard Filers for a Tax App
Machine LearningModel answerLast updated
Design an interpretable, recall-oriented classifier that predicts whether a tax-software user should itemize deductions, covering preprocessing, features, imbalance-aware metrics and time-aware validation.
Context
A consumer tax-preparation product wants to guess, early in the user's interview, whether a filer will be better off itemizing deductions or taking the standard deduction. The guess decides whether to send the user into the itemized-deduction flow (asking for mortgage interest, charitable gifts, state and local taxes, medical costs, and so on) or to skip it.
You have a historical dataset of about 1 million filer records with income sources, filing status, housing and mortgage details, donations, state and local taxes paid, and the deduction method finally chosen.
Task
Describe how you would build a classification model for this problem. Cover:
- Preprocessing: How do you encode categorical fields such as state of residence, and how do you treat missing values when users skip optional financial fields?
- Feature engineering: Which derived features or transformations would be most predictive of itemizing?
- Evaluation: Most filers take the standard deduction, so the classes are imbalanced. Which metrics do you prioritize, and why?
- Validation: What validation scheme respects the fact that data arrives in yearly filing seasons and that tax rules change?
Constraints
- About 1 million records.
- The model must be interpretable so it can pass compliance review.
- Recall on likely itemizers is prioritized, so that users do not miss savings and overpay.
State any assumptions you make, and explain your model choice and the trade-offs behind it.
Hints
Hint 1
Ask what the true decision rule is: itemizing wins when allowable itemized deductions exceed the standard deduction for that year and filing status. How can you put that comparison directly into a feature?
Hint 2
A skipped field is not the same as a zero. Think about keeping an explicit signal for 'unknown', and about which inputs are available at prediction time and which would leak the final answer.
Hint 3
For evaluation and validation, ask which error is costly and which is merely annoying, and why a random split across years would give misleadingly good numbers when the tax law changes.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Frame the problem first
The label is almost a deterministic rule: a filer should itemize when
allowable_itemized_total > standard_deduction(year, filing_status, age/blindness)
With every field filled in, a rules engine would suffice and ML would be unnecessary. The model earns its place because the prediction is needed early, while the profile is still partial, to route the user to the right screens. This framing matters for three reasons:
- It shows ML is used only where a rule cannot be applied yet.
- It explains why "distance from the threshold" will be the dominant feature.
- It highlights the main risk, leakage: only information available at prediction time may be used, never final deduction totals.
Scale is not an issue. With 1M rows and roughly 10% itemizers (about 100k positives), almost any model family has enough data.
1. Preprocessing
Categorical features
- Filing status (few levels): one-hot encode. It also sets the standard-deduction threshold.
- State (about 51 levels): one-hot works for a linear model. A more robust and explainable alternative is to replace the state with attributes: whether it has an income tax, its top marginal rate, and typical property-tax rates. These generalize across years and are easy to justify to reviewers.
- If you use target encoding, compute it out-of-fold and only from earlier years.
Missing values
- A skipped field is not a zero: the user may not own a home, or may not have reached that screen.
- Add a missingness indicator per optional field and impute zero (or a domain estimate such as wages × state tax rate) for the value. The indicator preserves the "unknown" signal.
- Do not drop incomplete rows. Partial profiles are the production distribution.
- Prefer imported documents (wage forms, mortgage statements, prior-year return) over self-reported numbers.
2. Feature engineering
Encode the tax logic into the inputs:
| Feature | Why it helps |
|---|---|
| Capped state and local taxes | The deduction is capped, so the raw sum overstates its value |
| Mortgage interest (within debt limits) | Typically the largest itemized item |
| Allowed charitable giving | Often the second driver, subject to income-based limits |
| Medical expenses above the AGI floor | Only the excess counts |
| Estimated itemized total | Sum of the components |
| Gap = estimated itemized total − standard deduction | The single strongest feature |
| Gap ratio (total / standard deduction) | Scale-free, so it transfers across years |
| Prior-year itemized flag | Strong persistence signal |
| Homeowner flag, log income, has-mortgage-document flag | Proxies when amounts are missing |
| Spouse-itemizes rule for married filing separately | Hard rule that forces the choice |
Normalizing by that year's standard deduction lets the model learn "how far from the gate" instead of memorizing dollar amounts, which is central to handling law changes.
Model choice and interpretability
- Logistic regression on the engineered gap features is transparent, quick to audit, and often close to the best model because the gap linearizes the problem. Plain polynomial expansion is less attractive: it hurts explainability and does not guarantee monotonic behavior.
- Constrained boosted trees (shallow, with monotonic constraints) or an Explainable Boosting Machine capture the sharp threshold. Per-feature shape functions or SHAP values give reason codes.
Recommendation: start with logistic regression, and move to a monotone GBM or EBM only if recall improves clearly. Then calibrate probabilities (Platt or isotonic) so thresholds are meaningful.
Imbalance: prefer class weights and threshold tuning over SMOTE. Synthetic financial profiles add little and complicate audits.
3. Evaluation
Accuracy is misleading: predicting "standard" for everyone is about 90% accurate.
- Recall on itemizers at the operating threshold (for example, a target of at least 95%), which follows directly from the "do not overpay" goal.
- Precision at that recall. False positives cost user time (extra screens) but not money, so they are tolerable, not free.
- PR-AUC to compare models, since ROC-AUC looks flattering under imbalance.
- F2 if a single number is needed that weights recall more than precision.
- Dollar-weighted miss cost: the sum over false negatives of (itemized − standard) × marginal rate. A missed $200 gap is not equal to a missed $15k gap.
- Calibration (Brier score, reliability curve) and sliced recall by state, filing status and income band to find failing segments and support compliance review.
4. Validation
- Forward-chaining split by tax year: train on years up to T−1, validate on T, test on T+1. Random splits across years leak future law and future behavior.
- Group by user: a filer appears in many years, so keep all of a user's records on one side of the split.
- Within-season order: early filers (simple wage returns) differ from late filers (more complex, more itemizers). Report metrics by filing week to see whether early-season behavior generalizes.
- Policy-shift backtest: train on years before a major law change (such as one that roughly doubled the standard deduction and cut the itemizing share sharply) and test just after. This shows how the design survives rule changes.
Common mistakes
- Using final Schedule-A totals or other post-decision fields as features.
- Reporting accuracy or ROC-AUC alone.
- Random train/test splits across years or users.
- Using raw dollar amounts instead of year-normalized gaps.
- Applying SMOTE to financial data and then being unable to explain the result to reviewers.
- Dropping rows with missing optional fields.
Follow-ups to be ready for
- Law changes: keep thresholds and caps in a versioned rules layer separate from the model, so the model consumes the gap and needs little retraining.
- Threshold choice: set it from the cost of an extra screen versus the expected dollars lost on a miss, not from a default 0.5.
- Monitoring: track recall by segment and the calibration drift each season.