Concepts 🚀 Project 🧮 Labs
🧮 Labs / Benchmark Engine / Classification metrics — accuracy, precision, recall, F1

Classification metrics — accuracy, precision, recall, F1

For classification models: accuracy, precision, recall, F1, confusion matrix. Each catches a different kind of failure.

script.py v3.1
Python output click Run to execute
Click "Run" to execute the code on the left.
The output will appear here.
🧠 How it works

4 metrics + 1 matrix: Accuracy — overall correctness. MISLEADING on imbalanced data (90% class 0 → 90% accuracy by always predicting 0). Precision — of all predicted positives, how many were actually positive? (spam filter: high precision = few false alarms) Recall — of all actual positives, how many did we catch? (cancer screening: high recall = few missed cases) F1 — harmonic mean of precision + recall. Use when you can't pick. Confusion matrix — 2x2 grid of TN, FP, FN, TP. The ground truth behind all metrics. ALWAYS look at the confusion matrix + class distribution before trusting accuracy.

✏️ Try these changes
  • Change weights from [0.9, 0.1] to [0.5, 0.5]
    → balanced data → accuracy becomes meaningful
  • Change n_estimators from 50 to 200
    → RF might improve recall
  • Add print(classification_report(y_test, rf.predict(X_test)))
    → per-class breakdown
  • Change the target to make_classification(n_classes=3, ...)
    → multi-class — metrics computed per-class