Machine Learning / Training & Evaluation
When accuracy lies and what to use instead.
Reviewed by Yuvaraj
Imagine a fraud detector that labels every transaction as legitimate. If only 1 in 1,000 transactions is actually fraud, this completely useless model is still 99.9% accurate. That single number hides a total failure. Choosing an evaluation metric is not paperwork you finish a project with, it encodes what you actually care about, and it decides which model you ship. This lesson walks through the core classification metrics built from the confusion matrix, touches ROC/AUC, covers the main regression metrics, and, most importantly, shows how to pick a metric that matches the cost of being wrong.
Every classification metric starts from four counts of how predictions line up with reality. For a binary problem with a "positive" class (say, fraud):
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actually Positive | True Positive (TP) | False Negative (FN) |
| Actually Negative | False Positive (FP) | True Negative (TN) |
These two errors usually have very different costs, which is exactly why a single accuracy number is dangerous.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
Accuracy is the fraction of all predictions that are correct. It breaks down on imbalanced data, where one class dominates, because predicting the majority class every time scores well while learning nothing.
Precision answers: of everything I flagged as positive, how much was right? Recall answers: of everything that was truly positive, how much did I catch? There is a tension between them, you can usually raise one by sacrificing the other.
The F1 score is the harmonic mean of the two, giving a single number that stays low unless both are reasonable:
Take a concrete confusion matrix: TP = 40, FP = 10, FN = 5, TN = 45 (100 predictions total).
Here recall is greater than precision, so this model misses fewer positives than it raises false alarms. Whether that trade-off is good depends entirely on your problem.
Most classifiers output a probability, and you pick a threshold to convert it to a label. The ROC curve plots the true positive rate against the false positive rate across all thresholds, and the AUC (area under that curve) summarizes it as one number from 0.5 (random) to 1.0 (perfect). AUC is threshold-independent and useful for ranking quality, but on heavily imbalanced data a precision-recall curve often tells a more honest story.
When the target is a continuous number, you measure the size of prediction errors instead of counting them:
Use RMSE when large errors are especially costly; use MAE when every unit of error matters equally.
Common mistakes