File size: 7,237 Bytes
771badf
 
2b00ed1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771badf
 
2b00ed1
771badf
2b00ed1
771badf
2b00ed1
 
 
771badf
2b00ed1
771badf
2b00ed1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b8e5d2
2b00ed1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
---
license: mit
language:
- en
tags:
- fraud-detection
- binary-classification
- tabular-classification
- explainable-ai
- xai
- trustworthy-ai
- responsible-ai
- finance
- scikit-learn
- lead-ai-labs
- synthetic-data
pipeline_tag: tabular-classification
library_name: sklearn
---

# πŸ” Lead.AI Fraud Detection Model

### Binary Fraud / Safe Classifier with Risk Score and Plain-Language Explanation

[![Try Live Demo](https://img.shields.io/badge/Try%20Live%20Demo-Fraud%20XAI%20Space-blue?style=for-the-badge)](https://huggingface.co/spaces/arun-gharami/fraud-detection-xai-demo)
[![Deploy via Lead.AI Labs](https://img.shields.io/badge/Deploy%20This%20Model-lead--ai.us-FF6B35?style=for-the-badge)](https://www.lead-ai.us)
[![Contact](https://img.shields.io/badge/Commission%20Custom%20Build-LinkedIn-0A66C2?style=for-the-badge&logo=linkedin)](https://www.linkedin.com/in/arunkgharami)

> Built by [Arun Kumar Gharami](https://huggingface.co/arun-gharami) Β· [Lead.AI Labs](https://www.lead-ai.us)

---

## The Business Problem This Solves

Your payment stack processes transactions in milliseconds. Fraudulent ones look identical
to legitimate ones β€” until the chargeback arrives weeks later. By then you've shipped the
goods, paid the processing fee, and absorbed the dispute cost.

**This model scores every transaction as Fraud or Safe in real time, with a risk probability
and a human-readable reason** β€” so your team knows not just *what* to block, but *why*.

---

## What It Returns

```json
{
  "prediction": "Fraud",
  "risk_score": 0.91,
  "explanation": "High transaction velocity in the past hour, new account, and international flag are the primary risk drivers."
}
```

| Output | Values | Business meaning |
|--------|--------|-----------------|
| `prediction` | `Fraud` / `Safe` | Binary routing decision |
| `risk_score` | 0.0–1.0 | Tune your own threshold β€” e.g. >0.7 = manual review |
| `explanation` | Plain English | Audit trail for disputes, compliance, chargebacks |

> Need three risk tiers instead of binary? See the extended
> [Lead.AI Fraud Shield](https://huggingface.co/arun-gharami/lead-ai-fraud-shield)
> (Low / Medium / High with confidence score).

---

## Who Should Use This

| Business Type | Use Case |
|--------------|----------|
| Banks & credit unions | Real-time transaction monitoring |
| Lending platforms | Application and disbursement fraud |
| Fintech startups | Fraud layer before you can afford a dedicated risk team |
| Internal risk / ops | First-pass automated triage before analyst review |
| Researchers | Baseline binary fraud classifier for benchmarking |

---

## Input Features

| Feature | Type | Description |
|---------|------|-------------|
| `transaction_amount` | float | Transaction value |
| `transaction_hour` | int | Hour of day (0–23) |
| `account_age_days` | int | Days since account creation |
| `previous_chargebacks` | int | Historical chargeback count |
| `transaction_velocity_1h` | int | Transactions in last 1 hour |
| `transaction_velocity_24h` | int | Transactions in last 24 hours |
| `is_international` | int | 1 = international transaction |
| `is_high_risk_merchant` | int | 1 = high-risk merchant category |
| `customer_risk_score` | float | Aggregated customer risk (0.0–1.0) |

---

## Integration Example

```python
import joblib
import pandas as pd

model = joblib.load("model/model.joblib")

txn = pd.DataFrame([{
    "transaction_amount": 850.0,
    "transaction_hour": 2,
    "account_age_days": 12,
    "previous_chargebacks": 2,
    "transaction_velocity_1h": 5,
    "transaction_velocity_24h": 18,
    "is_international": 1,
    "is_high_risk_merchant": 1,
    "customer_risk_score": 0.87
}])

label = model.predict(txn)           # "Fraud"
score = model.predict_proba(txn)     # [[0.09, 0.91]]
```

**Integration time:** ~2 hours for a developer familiar with Python REST APIs.

---

## Live Demo

**Don't take our word for it β€” try it yourself:**

πŸ–₯️ **[Fraud Detection XAI Demo β†’](https://huggingface.co/spaces/arun-gharami/fraud-detection-xai-demo)**

Adjust sliders, submit a transaction, and see the fraud/safe decision with a live explanation.
Share the demo link directly with stakeholders who need to approve the AI budget.

---

## Explainability β€” the Feature That Closes Disputes

Most fraud models are black boxes. This one tells you *why* it flagged a transaction.

That matters for three reasons:
1. **Disputes:** "The transaction was flagged because of high velocity, new account, and international origin" is a defensible audit trail
2. **Analyst efficiency:** Reviewers who see a reason take 60–80% less time per decision
3. **Compliance:** Financial regulators increasingly expect decision transparency for automated systems

---

## Deployment Options

| Option | Description | Time |
|--------|-------------|------|
| **Python direct** | `joblib.load()` + your API wrapper | ~2 hours |
| **Gradio demo** | Run `app.py` for a visual interface | ~30 min |
| **FastAPI wrapper** | See `sample_api_usage.py` | ~1 day |
| **Production custom build** | Retrained on your data, your infra | [Contact us](https://www.lead-ai.us) |

---

## Want This in Production?

- βœ… Retrained on **your actual transaction history**
- βœ… Threshold tuning matched to your chargeback tolerance
- βœ… REST API with authentication, rate limiting, and logging
- βœ… Integration with Stripe, Braintree, Adyen, or custom payment stack
- βœ… Live monitoring dashboard with fraud rate trends
- βœ… Monthly model refresh as fraud patterns evolve

**β†’ [Commission a custom build at lead-ai.us](https://www.lead-ai.us)**  
**β†’ [Connect on LinkedIn](https://www.linkedin.com/in/arunkgharami)**

---

## Responsible AI & Limitations

- Trained on synthetic data β€” real-world validation required before production use
- No regulatory certification (FFIEC, PCI-DSS, GDPR, etc.)
- Must not be used as the sole basis for fraud enforcement without human review
- False positive rate must be tuned per business β€” defaults are not production-ready

---

## Related Assets

| Asset | Description |
|-------|-------------|
| [Lead.AI Fraud Shield](https://huggingface.co/arun-gharami/lead-ai-fraud-shield) | Extended 3-tier scorer with confidence % |
| [Fraud Dataset v2 (100K)](https://huggingface.co/datasets/arun-gharami/lead-ai-fraud-detection-dataset-v2) | Training data β€” 21 features, 100K rows |
| [XAI Demo Space](https://huggingface.co/spaces/arun-gharami/fraud-detection-xai-demo) | Live interactive demo |

---

## Citation

```bibtex
@misc{gharami2024frauddetection,
  author       = {Arun Kumar Gharami},
  title        = {Lead.AI Fraud Detection Model: Binary Transaction Fraud Classifier with XAI},
  year         = {2024},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/arun-gharami/lead-ai-fraud-detection-model}}
}
```

---

## License

MIT β€” Free to use. For a production deployment with support SLA, contact [lead-ai.us](https://www.lead-ai.us).

---

*Lead.AI Labs β€” Trustworthy AI Systems for Practical Business Intelligence*  
[lead-ai.us](https://www.lead-ai.us) Β· [LinkedIn](https://www.linkedin.com/in/arunkgharami) Β· [GitHub](https://github.com/Arungharami)