Evaluating a fraud detection model with accuracy alone is dangerously misleading. Because genuine transactions vastly outnumber fraudulent ones in the credit card dataset, a naive classifier that labels every transaction as genuine can achieve 99%+ accuracy while catching zero fraud. FFD therefore evaluates all six classifiers — Random Forest, SVM, KNN, Naive Bayes, XGBoost, and LightGBM — across a complementary set of metrics: precision, recall, F1-score, and the full confusion matrix. Together these metrics reveal not just how often a model is right, but which kinds of errors it makes and how costly those errors are in a fraud context.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Antisource/FFD/llms.txt
Use this file to discover all available pages before exploring further.
Accuracy
Accuracy measures the overall fraction of predictions that are correct across both classes. Formula:Precision
Precision answers: “Of all the transactions my model flagged as fraud, what fraction were actually fraudulent?” Formula:Recall (Sensitivity)
Recall answers: “Of all the actual fraudulent transactions, what fraction did my model catch?” Formula:F1-Score
The F1-score is the harmonic mean of precision and recall, providing a single balanced metric when both false positives and false negatives matter. Formula:Classification Report
scikit-learn’sclassification_report generates a formatted per-class breakdown of all key metrics in a single call, covering both the genuine (Class 0) and fraudulent (Class 1) classes.
| Column | Meaning |
|---|---|
precision | Fraction of predicted positives that are true positives for that class |
recall | Fraction of actual positives correctly identified for that class |
f1-score | Harmonic mean of precision and recall for that class |
support | Number of actual instances of that class in y_test |
| Row | Meaning |
|---|---|
0 (genuine) | Metrics computed with Class 0 as the positive class |
1 (fraud) | Metrics computed with Class 1 as the positive class — the rows to focus on |
macro avg | Unweighted mean of per-class metrics — treats both classes equally regardless of support |
weighted avg | Support-weighted mean — dominated by the majority class (genuine) on imbalanced data |
On a highly imbalanced fraud dataset, the
weighted avg row is dominated by Class 0 (genuine transactions) and can look deceptively strong. Always inspect the Class 1 row directly to assess the model’s actual fraud detection capability.Confusion Matrix
The confusion matrix provides a complete breakdown of prediction outcomes for binary classification, making every type of error visible at a glance.| Cell | Name | Description | Cost |
|---|---|---|---|
| Top-left | True Negative (TN) | Genuine transaction correctly identified as genuine | None — correct outcome |
| Top-right | False Positive (FP) | Genuine transaction incorrectly flagged as fraud | Low-to-medium — false alarm, customer friction |
| Bottom-left | False Negative (FN) | Fraudulent transaction missed, labeled as genuine | High — undetected fraud, direct financial loss |
| Bottom-right | True Positive (TP) | Fraudulent transaction correctly identified as fraud | None — correct outcome |
Choosing the Right Metric
Use this table to guide metric selection based on the operational priority of your deployment:| Priority | Metric to Maximize | Why |
|---|---|---|
| Minimize missed fraud (False Negatives) | Recall | Catches the largest fraction of actual fraud; reduces undetected financial loss |
| Minimize false alerts (False Positives) | Precision | Reduces unnecessary account freezes and customer friction |
| Balance both types of error | F1-Score | Harmonic mean penalizes extreme imbalance between precision and recall |
| Overall sanity check | Accuracy | Useful only when classes are balanced; always pair with the above metrics on fraud data |
For model comparison across the six FFD classifiers, prioritize the Class 1 recall and F1-score columns from the classification report. A model that ranks first on accuracy but second on recall may be the worse production choice depending on the fraud cost tolerance of the deployment environment.