Understanding precision and recall in classification
Precision and recall answer different questions about classifier performance. Precision asks: when my model predicts positive, how often is it right? Recall asks: when the truth is positive, how often does my model catch it? A spam filter with high precision lets few legitimate emails slip into spam; high recall ensures few spam emails reach the inbox. The tension between them defines the fundamental tradeoff in classification.
In imbalanced datasets, both metrics matter. A model predicting 'negative' on everything can achieve 95% accuracy on a dataset that is 95% negative, but zero recall. Precision and recall expose this deception by forcing you to measure against the positive class, not the dominant class.
When to optimize each metric
Choose your primary metric based on the cost of mistakes. Medical screening demands high recall: missing a disease is catastrophic. Fraud detection demands high precision: falsely flagging legitimate transactions costs customer trust. Most systems live on a curve where precision declines as you chase higher recall, and vice versa. The operating point you choose depends on how your domain weighs false positives against false negatives.