Top 10 Most Important Machine Learning Topics · Question 06

In an imbalanced classification problem, how do you choose between precision and recall, and how do you select the decision threshold?

Interview preparation resource from Gate Smashers.

Interview-ready answer

Precision measures how many predicted positives are correct, while recall measures how many actual positives are found. I prioritize precision when false positives are expensive and recall when false negatives are expensive. I do not choose the metric or threshold from accuracy alone; I use the business cost, class prevalence, a precision–recall curve and validation data, then confirm the selected threshold on an untouched test set and monitor it in production.

Most Important Machine Leaning Topics diagram explaining In an imbalanced classification problem, how do you choose between precision and recall, and how do you select the decision threshold
Confusion matrix
Predicted positivePredicted negative
Actually positiveTrue Positive (TP)False Negative (FN)
Actually negativeFalse Positive (FP)True Negative (TN)
Precision

Among predicted positives, precision is the fraction that is actually positive.

Recall

Among actual positives, recall is the fraction successfully detected.

F1 score

F1 is the harmonic mean of precision and recall. It is useful when both matter, but it does not encode every business cost.

Understand it clearly

Start with the confusion matrix

Precision and recall describe different errors. Precision decreases when false positives increase. Recall decreases when false negatives increase. The correct priority therefore depends on the consequence of each error, not on a universal rule.

Scenario-based choice

  • Spam filtering: Excessive false positives may hide legitimate mail, so precision can be especially important.
  • Serious-disease screening: Missing a positive case may be costly, so high recall is often prioritized, followed by a confirmatory test.
  • Fraud investigation: The operating point must balance recovered fraud against the limited capacity of investigators and customer friction.
  • Search or recommendations: Precision@K and Recall@K may be more meaningful than unrestricted binary metrics because only a ranked shortlist is shown.

Threshold selection

A classifier score is converted into a class by a threshold. Lowering the threshold usually increases recall and false positives; raising it usually increases precision and false negatives. Choose the threshold on validation data by optimizing a stated constraint or utility, such as maximum recall while maintaining precision above 90%, or minimum expected business cost.

Why accuracy can mislead

If only 1% of examples are positive, predicting every example as negative produces 99% accuracy and zero recall. Always inspect prevalence, the confusion matrix and metrics that reflect the actual decision.

Production considerations

Precision changes when class prevalence changes, even if the score distributions are otherwise similar. Monitor calibration, prevalence, threshold-specific metrics and delayed labels. Revisit the threshold when costs, capacity or the data distribution changes.