architectraghu's picture
Upload README.md
d68293c verified
---
license: mit
tags:
- cbc-reference-model
- mlops-100-day
- fraud-detection
- tabular-classification
---
# CBC Reference Model: Credit-Card Fraud Detection
> Pre-trained reference model for the **CBC [MLOps 100-Day Track](https://github.com/careerbytecode/cbc-learning-hub/tree/main/100-days/mlops)** (Capstone 2). Published twin of ML Development Capstone 2.
## Model details
- **Type:** XGBoost classifier (Optuna-tuned, `scale_pos_weight=498`), trained on a **time-aware** split (earlier 80% of transactions by Time; tested on the latest 20%).
- **Framework:** xgboost 3.2.0 · **Serialization:** joblib · **Seed:** 42
- A **pre-filter** that ranks transactions by fraud risk for review — NOT an automated block. `scale_pos_weight` de-calibrates probabilities upward, so the operating threshold is high (not 0.5) and is a serving config, recorded in `metrics.json`.
## Intended use
Flag transactions for human/downstream review. Teaching/reference artifact — not a production authorization system.
## Training data
ULB mlg-ulb credit-card fraud (284,807 transactions over two days, 492 frauds, 0.17%). 28 PCA features V1..V28 + Amount; Time is the split variable. ODbL/DbCL.
## Metrics (latest-20%-by-Time test split, evaluated once)
| Metric | Value |
|---|---|
| PR-AUC | 0.8050 (no-skill floor 0.0013) |
| ROC-AUC | 0.9656 |
| Recall @ threshold 0.7017 | 0.7467 |
| Precision @ threshold | 0.8750 |
| F1 @ threshold | 0.8058 |
Threshold 0.7017 was tuned on a validation slice for precision >= 90%. Top SHAP drivers: V4 (2.61), V14 (2.29), V12 (1.76), V10 (1.34), V11 (1.19).
## How to load and predict
```python
import joblib, json, pandas as pd
from huggingface_hub import hf_hub_download
model = joblib.load(hf_hub_download("careerbytecode/mlops-ref-finance-fraud", "model/pipeline.joblib"))
sample = json.load(open(hf_hub_download("careerbytecode/mlops-ref-finance-fraud", "sample_input.json")))
proba = float(model.predict_proba(pd.DataFrame([sample]))[0, 1])
is_fraud = proba >= 0.7017 # threshold from metrics.json
print(proba, is_fraud)
```
Input schema: 29 numeric columns — V1..V28 (PCA) + Amount.
## Limitations
- Severely imbalanced (0.17%): accuracy is meaningless; judge by PR-AUC vs floor and recall/precision at threshold.
- Features are PCA components — not human-readable; SHAP names components, not transaction attributes.
- Temporal drift expected; retrain on a rolling window. Reference/teaching artifact only.
---
© 2015-2026 CareerByteCode. All rights reserved. | CC BY-NC-SA 4.0 (docs), MIT (code) | Authored by Raghavendra R, Platform Owner CareerByteCode, Solution Architect