Contents
09Interview questions and model answers
Q1Why is accuracy a bad metric for fraud detection?
Fraud is rare (0.15\% of transactions on our test day), so the true negatives dominate the confusion matrix. A model that never flags anything is 99.85\% accurate and catches no fraud; a useful model scored 99.90\%. Accuracy measures mostly the prevalence; we need metrics that look at the positives.
Q2Define precision and recall. When do you favor each?
Precision =\mathrm{TP}/(\mathrm{TP}+\mathrm{FP}): of the alarms, the share that are real. Recall =\mathrm{TP}/(\mathrm{TP}+\mathrm{FN}): of the real positives, the share we catch. Favor precision when false alarms are costly or limited (spam filters, a fixed team of investigators, the first page of search results); favor recall when misses are costly (cancer screening, safety-critical defects). At the threshold \tau=0.5 (flag when the fraud probability p\ge0.5) our model had P=72\% and R=56\%; lowering \tau to 0.1 gave 54\% and 70\%.
Q3Why is F_1 a harmonic mean and not an arithmetic one?
The harmonic mean 2PR/(P+R) is at most twice the smaller of the two, so it cannot be inflated by one perfect value. Flag-everything has recall 1 and precision equal to the prevalence: arithmetic mean about 50\%, F_1 about 2\pi, where \pi is the prevalence. F_1=2\mathrm{TP}/(2\mathrm{TP}+\mathrm{FP}+\mathrm{FN}) ignores true negatives. Use F_\beta with \beta>1 to favor recall, \beta<1 to favor precision.
Q4What is a ROC curve, and what does the AUC mean?
The true positive rate against the false positive rate as the threshold sweeps from high to low. The area under it equals the probability that a randomly chosen positive gets a higher score than a randomly chosen negative (ties count half), the Mann–Whitney statistic U/(n_+n_-), where U counts the (positive, negative) pairs won by the positive and n_+, n_- are the numbers of positives and negatives. 0.5 is random, 1 is perfect. Ours: 0.958, and the fraud won 96\% of 10{,}000 random pairs.
Q5ROC-AUC or precision–recall AUC for imbalanced data?
ROC uses rates within each class, so it ignores the prevalence, and with rare positives a tiny false positive rate can still mean many false alarms: at \mathrm{FPR}=1\% our model raised 1{,}348 false alarms for 174 frauds, a precision of 11\%. The precision–recall curve shows this; its random baseline is the prevalence. Use average precision when positives are rare and the cost of acting on alarms matters; use ROC-AUC to compare rankings across data sets with different prevalences.
Q6Derive precision from the true positive rate, the false positive rate and the prevalence.
By Bayes’ rule, P=\mathrm{TPR}\,\pi/(\mathrm{TPR}\,\pi+\mathrm{FPR}(1-\pi)). At fixed rates, precision falls as positives become rarer: the COVID-19 test with sensitivity 87.5\% and specificity 97.5\% has precision 79.5\% at prevalence 10\% but 26\% at 1\% (Murphy, 2022, §2.3.1).
Q7How do you choose a classification threshold?
From costs: flag when p\ge C_{\mathrm{FP}}/(C_{\mathrm{FP}}+C_{\mathrm{FN}}), which assumes calibrated probabilities; if a miss costs 25 false alarms, \tau=1/26. Otherwise, or to check, choose the threshold that optimizes the business metric (cost, F_\beta, precision at a required recall, alarms per day) on validation data, never on the test set. Revisit it when the prevalence changes.
Q8A model has AUC 0.96. Can you use its scores as probabilities?
Not without checking. AUC depends only on the ranking; any increasing transformation of the scores leaves it unchanged. Squashing our scores into [0.49,0.51] kept AUC at 0.958 while the log loss went from 0.0046 to 0.693. Check calibration with log loss, the Brier score or a reliability diagram, and recalibrate if needed.
Q9How do you compute F_1 for more than two classes?
One-against-rest per class, then average: macro (the mean of the per-class F_1 values, every class equal) or micro (pool \mathrm{TP}, \mathrm{FP}, \mathrm{FN} first). For single-label problems micro-F_1 equals accuracy, so it hides rare classes; macro-F_1 does not. On our data at \tau=0.5: macro 0.815, micro 0.999.
Q10How much would you trust an AUC of 0.958 computed on 211 frauds?
The Hanley–McNeil standard error is about 0.0096 (a stratified bootstrap gives 0.0101, interval 0.938 to 0.976). With many more negatives than positives, \mathrm{SE}\approx\sqrt{(Q_2-A^2)/n_+}: the number of positives limits the precision, so an AUC difference of 0.01 between two models on this test set may be noise.