MLCrack

    CLASSICAL ML · INTERVIEW QUESTION

    Explain precision, recall, F1-score, and when to use each.

    🟡 intermediate · Supervised Learning

    Hint: Think about the confusion matrix and different error costs.

    Answer

    Precision = TP/(TP+FP): of predicted positives, how many are correct? High precision = few false alarms. Recall = TP/(TP+FN): of actual positives, how many did we find? High recall = few misses. F1 = 2·P·R/(P+R): harmonic mean, balances both.

    When to use: Precision: when false positives are costly (spam filtering — don't block legit email). Recall: when false negatives are costly (cancer detection — don't miss cases). F1: when you need a single balanced metric. F-beta: F_β = (1+β²)·P·R/(β²·P+R). β>1 weights recall more, β<1 weights precision more.

    For imbalanced data: use precision-recall curves and AUPRC instead of ROC/AUC.

    Always consider the business cost of each error type.