← 📊 Data Science & Machine Learning

📊 Class-Imbalance Lab

True negatives
False positives
False negatives (missed)
True positives
Accuracy:
Precision:
Recall (sensitivity):
F1-score:
FPS:
Drag — rotate · Scroll — zoom

📊 The Class-Imbalance Trap

A 3D cloud of simulated patients splits into a rare "disease" minority and a large "healthy" majority; a moveable decision plane classifies them, and live TP/FP/FN/TN counts show how accuracy can stay high while F1-score collapses.

🔬 What It Demonstrates

When disease prevalence is low, a threshold that maximizes accuracy tends to push almost everyone into "healthy," inflating accuracy while recall for the rare class collapses. F1-score, which balances precision and recall, exposes this immediately.

🎮 How to Use

Set disease prevalence and population size to rebuild the patient cloud, then drag the threshold slider to move the decision plane. Click "Optimize for Accuracy" vs "Optimize for F1" to see the boundary jump to two very different — and revealing — positions.

💡 Did You Know?

A classifier that always predicts "no disease" for a 2%-prevalence condition scores 98% accuracy while catching zero true cases — the exact failure mode the class-imbalance trap describes in rare-disease screening models.