Anomaly and Fraud Detection Questions
Detecting rare, abnormal, or adversarial events in data. Covers anomaly-detection techniques, fraud and risk modeling, handling extreme class imbalance, and the precision/recall and latency tradeoffs of real-time detection systems. Focuses on the modeling patterns unique to needle-in-a-haystack detection problems.
Give a concise explanation of how Isolation Forest detects anomalies: what makes a point easy to isolate, what score it produces, and one practical tip for using it on transaction data.
Sample Answer
Direct answer
Isolation Forest detects anomalies by exploiting the fact that outliers are easier to separate from the rest of the data than normal points are: it builds many random decision trees that split on random features at random thresholds, and a point that gets isolated (ends up alone in its own leaf) after only a few splits is scored as more anomalous than a point that takes many splits to isolate.
Structured elaboration
- What makes a point easy to isolate: normal points sit in dense regions, so a random split has to cut through a lot of similar neighbors before separating any single point out. An outlier sits far from the bulk of the data, so a single random split, or very few, is often enough to put it alone in its own partition.
- The score it produces: for each point, the algorithm averages the path length (the number of splits needed to isolate it) across many random trees, then converts that average into an anomaly score, typically normalized so scores close to 1 mean "very anomalous" (short average path length) and scores close to 0 mean "very normal" (long average path length).
- Practical tuning tip for transaction data: the contamination parameter (the expected fraction of anomalies) directly sets your decision threshold, so treat it as a business knob tied to your review-queue capacity rather than an accuracy-maximizing hyperparameter; setting it too high floods the queue with borderline cases, and setting it too low silently raises the score bar needed to get flagged at all.
Trade-offs and pitfalls
Isolation Forest works well on continuous numeric features but degrades on high-cardinality categorical fields (like merchant identifiers) unless they're encoded thoughtfully first, and it has no built-in way to use confirmed fraud labels even when some exist, since it is a purely unsupervised method. When labels are available, even a small amount, a supervised or semi-supervised approach usually outperforms a pure Isolation Forest on the specific fraud patterns those labels cover, while Isolation Forest remains valuable for catching genuinely novel patterns no labeled example has ever seen.
Design a system for incorporating fraud analysts' review decisions back into model retraining and feature development, without introducing new label bias from the fact that analysts only ever see the cases the model already flagged. What would you record about each analyst decision, and how would you use it responsibly?
Sample Answer
Direct answer
Record what an analyst decided and why, tied to the specific case and the model's own prediction at the time, and treat every analyst decision as coming from a biased sample (only cases the model already flagged), correcting for that bias when using the decisions to retrain, rather than treating analyst-reviewed outcomes as if they were a random, representative sample of all traffic.
Structured elaboration
- What to record per decision: the case's model score and the specific features that drove it, the analyst's final decision (confirmed fraud, confirmed legitimate, or genuinely uncertain), a brief reason code capturing WHY (which is far more useful for later analysis than a bare label), and the analyst's confidence level, since not every "confirmed legitimate" decision is equally certain.
- Why the selection bias matters: analysts only ever see cases the model already flagged as suspicious, so their decisions are not a representative sample of the whole traffic population; if you naively retrain treating analyst-confirmed "legitimate" cases the same as a random sample of ordinary transactions, you bias the model toward learning "the borderline cases analysts see" rather than the true, full population's actual decision boundary.
- Using the feedback responsibly: fold analyst decisions back into training with an explicit awareness of this selection bias, for example by using them primarily to REFINE the model's behavior specifically in the score range analysts actually review (correcting overconfident or underconfident scoring near the threshold), rather than treating them as equally informative everywhere in score space; and periodically sample a small amount of UNFLAGGED, lower-scored traffic for review too, specifically to check whether the model is systematically missing something outside its current flagged range, since analyst feedback alone can never surface that.
- Avoiding introducing NEW bias: track analyst-level patterns over time (is one analyst systematically more or less strict than others, does confidence correlate with time-of-day or workload) so the system can account for reviewer-level variation rather than treating every analyst decision as equally reliable ground truth.
Trade-offs and pitfalls
The single easiest mistake here is treating analyst-confirmed "legitimate" as equivalent to a random, unbiased negative example during retraining, which silently reinforces whatever the model already believed rather than correcting it, since those are, almost by definition, the cases the model was already uncertain enough about to flag for review in the first place. Building in periodic sampling of never-flagged traffic, even though it costs reviewer time that isn't directly tied to a known suspicious case, is the main structural defense against this feedback loop quietly narrowing the model's view of the world.
Explain Positive-Unlabeled learning and when it is the right framing for a fraud dataset where many of the legitimate labels are really just unconfirmed, and some fraction of them are actually undiscovered fraud. How would this kind of label noise change how you validate a model compared to a dataset with clean labels?
Sample Answer
Direct answer
Positive-Unlabeled learning fits a fraud dataset where you have some confirmed fraud cases (the positives) but the rest of the data is simply unlabeled rather than confirmed legitimate, since many transactions that look "not fraud" are really just never investigated, not verified clean. When some of those unlabeled negatives are actually undiscovered fraud, that label noise means a model validated against them as if they were clean will systematically underestimate both false positives (some "false positives" are actually correct catches of undiscovered fraud) and true detection performance.
Structured elaboration
- Why plain supervised learning breaks down here: standard supervised learning assumes your negative labels are correct. If a meaningful fraction of "not fraud" labels are really "never investigated, so unknown," the model is effectively being told some real fraud is legitimate, which both corrupts training and, more subtly, corrupts your evaluation metrics, since a case the model correctly flags as fraud but which was never confirmed will be scored as a false positive.
- One algorithmic approach: treat the unlabeled set as a mixture of hidden positives and true negatives, and use a method like PU bagging (training many classifiers, each treating a random subsample of the unlabeled set as negative, then averaging their scores) or a bias-corrected classifier that explicitly estimates the unknown positive fraction in the unlabeled set rather than assuming it's zero.
- How label NOISE specifically changes validation: if you validate the usual way (treating every unlabeled case as a confirmed negative), a model that's actually performing well will look artificially worse, since some of its "false positives" are real fraud your labels just haven't caught up to yet. A more honest validation approach is to specifically re-review a sample of the model's flagged-but-officially-unlabeled cases through manual investigation, rather than trusting the existing label set as ground truth for evaluation.
Trade-offs and pitfalls
PU-learning techniques generally require an estimate of what fraction of the unlabeled data is truly positive, and that estimate itself is often uncertain; get it meaningfully wrong and the bias-correction can do more harm than good. It's also worth periodically re-auditing older "unlabeled" cases as more time passes and more investigations complete, since the fraction of true positives hiding among them tends to shrink (though never fully disappear) the longer a case has had a chance to be reported.
What does label delay mean in fraud detection, for example a fraudulent transaction that is only confirmed as fraud weeks later through a chargeback, and why does it complicate both training and evaluating a model? Give two concrete strategies for handling it.
Sample Answer
Direct answer
Label delay means a transaction's true fraud status is not known at the time it happens; it is confirmed only later, for example when a customer disputes a charge and a chargeback is filed weeks after the original transaction. This matters because both training data and evaluation metrics computed too soon after a transaction will systematically undercount fraud, since some of the "confirmed legitimate" transactions in that recent window are actually undiscovered fraud that just hasn't been reported yet.
Structured elaboration
- Why it complicates training: if you build a training set from the most recent few weeks of transactions, some of the "negative" (not-fraud) labels in that window are wrong, they simply haven't had time to be confirmed as fraud yet. Training on a window that is too recent silently injects label noise that biases the model toward under-detecting fraud.
- Why it complicates evaluation: the same problem applies to a held-out test set, but the bias runs in opposite directions on the two metrics. If you evaluate a model's precision and recall using a window too close to "now," some of what you're counting as false positives are actually true positives whose confirmation just hasn't arrived, making precision look artificially worse than it actually is. Recall typically moves the other way and looks artificially inflated: fraud the model actually catches gets investigated and confirmed quickly (an analyst resolves the alert), while fraud the model misses only surfaces later through a slower customer chargeback, so the confirmed-positive set used to compute recall is skewed toward the cases the model already caught, understating how much real fraud is still slipping through unconfirmed.
- Strategy one, a confirmation buffer: only use transactions old enough that essentially all of the confirmations (chargebacks, investigations) that would ever arrive have had time to arrive, both for training labels and for evaluation. This is simple and robust but throws away the most recent, most relevant data.
- Strategy two, survival-analysis-style modeling of the delay: instead of waiting out the full delay window, model the fraud confirmation process itself as a time-to-event problem, treating not-yet-confirmed transactions as censored observations rather than confirmed negatives; this lets you use recent data without treating "not yet confirmed" as equivalent to "confirmed legitimate," at the cost of a more involved training and evaluation setup.
Trade-offs and pitfalls
The confirmation-buffer approach is simple to reason about but means your model is always trained and evaluated on data that is, by construction, somewhat stale relative to the current fraud landscape, which matters when fraud patterns evolve quickly. Whichever strategy you use, never silently treat "not yet confirmed" the same as "confirmed legitimate" when reporting evaluation metrics; state explicitly how old your evaluation window is, which direction each metric is likely biased, and what fraction of confirmations were likely still pending at label-collection time.
Describe how you would design a data-collection and labeling plan for a new fraud-detection project from scratch: what data sources you would pull from, how you would obtain labels for an event that is rare and only confirmed well after the fact, and what quality checks you would run before trusting the data enough to model on it.
Sample Answer
Direct answer
Pull from transaction logs, device and session telemetry, and any existing confirmed-fraud records (chargebacks, manual investigation outcomes) as the core data sources, obtain labels for a rare, delayed-confirmation event by combining an initial manual-investigation process with a waiting period long enough for chargebacks to arrive, and run data-quality checks (completeness, consistency, and a sanity check against a small manually-labeled sample) before trusting the collected data enough to build a model on it.
Structured elaboration
- Data sources: transaction logs (amounts, timestamps, merchants, destination accounts) form the core; device and session telemetry (device fingerprints, IP addresses, session behavior) add context that pure transaction data lacks; and any existing fraud-adjacent records (support tickets, manual investigation notes, chargeback data) provide the actual ground-truth labels once confirmed.
- Obtaining labels for a rare, delayed event: since confirmed fraud is both rare and slow to confirm, combine a manual-investigation workflow (a small team reviewing a sample of suspicious-looking transactions directly, to bootstrap an initial label set faster than waiting for organic chargebacks) with patience for the natural confirmation process (chargebacks, disputes) to fill in the rest over the following weeks; treat the manually-investigated labels as a faster, smaller, high-confidence set and the chargeback-derived labels as a slower, larger, still-reliable set.
- Data retention and privacy considerations: fraud investigation data often includes sensitive personal and financial information, so plan retention periods and access controls deliberately (who can see raw device/session data, how long it's kept, whether it needs to be anonymized or aggregated for model training) rather than defaulting to "keep everything indefinitely," which creates unnecessary compliance and privacy risk.
- Data-quality checks before modeling: check for basic completeness (are timestamps, amounts, and account identifiers reliably populated), consistency (do aggregated features match a manual recomputation on a small sample), and label sanity (manually re-review a random sample of "confirmed legitimate" cases to estimate how much hidden, unconfirmed fraud might be lurking in what you're about to treat as ground truth).
Trade-offs and pitfalls
It's easy to under-invest in the labeling plan because it feels like "not the modeling work," but a fraud project's ceiling is set almost entirely by its label quality, no amount of feature engineering or model sophistication fixes a training set with badly biased or incomplete labels. It's also worth revisiting the labeling plan periodically as the project matures, since the earliest labels (often collected under time pressure, from a narrow initial fraud pattern) can systematically under-represent fraud types that show up later.
Unlock Full Question Bank
Get access to all 34 Anomaly and Fraud Detection interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.