Adjust the class distribution to see why Accuracy is a dangerously misleading metric when dealing with imbalanced datasets like fraud detection or rare diseases.
In many real-world scenarios, the data we care about is rare. Think of credit card fraud, rare disease detection, or critical system failures. In these datasets, the "normal" class vastly outnumbers the "anomaly" class. This is called Label Imbalance, and it creates a dangerous trap for machine learning models: The Accuracy Paradox.
The Accuracy Paradox occurs when a model achieves a very high accuracy score but is completely useless in practice. This happens because the model learns to simply predict the majority class every single time. In a dataset with 99% normal transactions and 1% fraudulent ones, a model that always guesses "normal" will be 99% accurate. It sounds great, but it has failed at its one important job: detecting fraud.
This visualization demonstrates the paradox by comparing two models:
This is a deliberately dumb model. Its only rule is: always predict Class 0 (the majority class). It never predicts an anomaly. As you'll see, its accuracy is deceptively high.
This is a standard Logistic Regression model. It tries to learn a decision boundary to separate the two classes based on the data. Watch how its behavior and metrics change as the dataset becomes more imbalanced.
Use the interactive panel to build a strong intuition for this problem.
The paradox teaches us a critical lesson: accuracy is not the right metric for imbalanced datasets. We need to look at metrics that tell us how well the model performs on the minority class.
When dealing with imbalanced data, always evaluate your model using a Confusion Matrix, and pay close attention to Precision, Recall, and the F1-Score, especially for the rare class you are trying to find.
In many real-world scenarios, the data we care about is rare. Think of credit card fraud, rare disease detection, or critical system failures. In these datasets, the "normal" class vastly outnumbers the "anomaly" class. This is called Label Imbalance, and it creates a dangerous trap for machine learning models: The Accuracy Paradox.