File size: 5,206 Bytes
1ec3568
 
 
 
 
 
 
 
 
 
 
 
5db1d3e
 
 
1ec3568
 
 
 
5db1d3e
 
 
 
 
 
1ec3568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5db1d3e
 
 
cc4955d
5db1d3e
 
 
 
 
 
 
 
cc4955d
 
 
 
5db1d3e
 
 
 
 
 
 
 
 
 
 
 
1ec3568
5db1d3e
1ec3568
5db1d3e
1ec3568
5db1d3e
1ec3568
5db1d3e
1ec3568
 
 
 
5db1d3e
1ec3568
5db1d3e
 
1ec3568
 
5db1d3e
1ec3568
 
 
 
 
 
5db1d3e
1ec3568
 
 
5db1d3e
 
 
 
 
1ec3568
 
 
 
 
5db1d3e
1ec3568
 
 
 
5db1d3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ec3568
 
5db1d3e
 
 
1ec3568
 
5db1d3e
 
 
 
 
 
 
 
 
 
 
 
 
1ec3568
 
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
---
title: "Death Legion Fraud Detection"
emoji: "๐Ÿ”ฅ"
colorFrom: "red"
colorTo: "red"
sdk: "gradio"
sdk_version: "4.19.0"
python_version: "3.10"
app_file: "app.py"
pinned: false
---

# ๐Ÿ”ฅ Death Legion Fraud Detection System

<p align="center">
<img src="https://img.shields.io/badge/Death%20Legion-Powered-red?style=for-the-badge&logo=skull" alt="Death Legion">
<img src="https://img.shields.io/badge/Best%20Teams-Elite-gold?style=for-the-badge&logo=crown" alt="Best Teams">
<img src="https://img.shields.io/badge/AUPRC-0.8177-success?style=for-the-badge" alt="AUPRC">
<img src="https://img.shields.io/badge/Model%20Size-6.12MB-blue?style=for-the-badge" alt="Size">
</p>

## ๐ŸŽฏ Overview

Welcome to the **Death Legion Fraud Detection System** - a state-of-the-art machine learning solution for real-time credit card fraud detection. Built by the **Best Teams** with cutting-edge Random Forest technology, this model achieves exceptional performance on highly imbalanced financial datasets.

## ๐Ÿš€ Deploy This Space

<p align="center">
<a href="https://huggingface.co/spaces/Pnny13/fraud-detection-space?duplicate=true">
<img src="https://img.shields.io/badge/๐Ÿš€%20Deploy%20to%20HF-Spaces-blue?style=for-the-badge" alt="Deploy to Hugging Face">
</a>
</p>

## ๐ŸŽฎ Use This Model

<p align="center">
<a href="https://huggingface.co/Pnny13/fraud-detection-model">
<img src="https://img.shields.io/badge/๐Ÿค—%20Use%20This%20Model-Hugging%20Face-yellow?style=for-the-badge" alt="Use This Model">
</a>
</p>

## โšก Key Features

- **๐Ÿ›ก๏ธ Advanced Random Forest Architecture**: 500 estimators with optimized depth
- **๐Ÿ“Š Superior Performance**: AUPRC 0.8177 on imbalanced fraud data
- **๐Ÿ”’ Secure Safetensors Format**: Fast, safe model serialization
- **โšก Real-time Inference**: Sub-millisecond prediction latency
- **๐ŸŽฏ Imbalanced Data Optimized**: Precision-Recall focused evaluation

## ๐Ÿ“ˆ Performance Metrics

| Metric | Score | Status |
|--------|-------|--------|
| **AUPRC** | 0.8177 | โœ… Excellent |
| **Precision** | 0.8182 | โœ… High |
| **Recall** | 0.8265 | โœ… Strong |
| **F1-Score** | 0.8223 | โœ… Balanced |

## ๐Ÿ—๏ธ Model Architecture

```
Random Forest Classifier
โ”œโ”€โ”€ Estimators: 500
โ”œโ”€โ”€ Max Depth: 25
โ”œโ”€โ”€ Features: 30 (V1-V28 + Time + Amount)
โ”œโ”€โ”€ Classes: 2 (Legitimate, Fraudulent)
โ””โ”€โ”€ Format: Safetensors (6.12 MB)
```

## ๐Ÿ“– How to Use

### Quick Start

1. **Access the Live Demo**: Visit [https://huggingface.co/spaces/Pnny13/fraud-detection-space](https://huggingface.co/spaces/Pnny13/fraud-detection-space)

2. **Enter Transaction Features**: Input the 30 features (V1-V28, Time, Amount) from your credit card transaction

3. **Get Instant Prediction**: The system will return:
   - Fraud probability score (0-100%)
   - Binary classification (Fraud/Legitimate)
   - Recommendation for action

### Programmatic Usage

```python
from safetensors.numpy import load_file
import numpy as np

# Load model from Hugging Face Hub
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
    repo_id="Pnny13/fraud-detection-model",
    filename="fraud_detector.safetensors"
)

# Load and predict
tensors = load_file(model_path)
# ... use model for predictions
```

## ๐Ÿ“ Repository Structure

```
Pnny13/fraud-detection-space/
โ”œโ”€โ”€ app.py              # Gradio application
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ””โ”€โ”€ README.md           # Documentation

Pnny13/fraud-detection-model/
โ”œโ”€โ”€ fraud_detector.safetensors  # Trained model
โ”œโ”€โ”€ scaler.joblib               # Feature scaler
โ”œโ”€โ”€ inference.py                # Prediction script
โ””โ”€โ”€ README.md                   # Model documentation
```

## ๐Ÿ”ฌ Technical Details

### Dataset
- **Source**: [Kaggle - Credit Card Fraud Detection](https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud)
- **Transactions**: 284,807 total
- **Fraud Cases**: 492 (0.172% - highly imbalanced)
- **Features**: 30 PCA-transformed features + Time + Amount

### Preprocessing
- **Robust Scaling**: Applied to Time and Amount features
- **Feature Engineering**: PCA components V1-V28
- **Class Balancing**: Optimized for precision-recall tradeoff

### Training Configuration
```python
RandomForestClassifier(
    n_estimators=500,
    max_depth=25,
    class_weight='balanced_subsample',
    random_state=42,
    n_jobs=-1
)
```

## ๐ŸŽฎ Live Demo

Try the live interactive demo at: **https://huggingface.co/spaces/Pnny13/fraud-detection-space**

## ๐Ÿค Credits

<p align="center">
<strong>Powered by Death Legion</strong><br>
<em>Elite Machine Learning Division</em>
</p>

<p align="center">
<strong>Best Teams Collaboration</strong><br>
<em>Excellence in AI Engineering</em>
</p>

## ๐Ÿ“œ License

This model is released under the MIT License. Use responsibly for fraud detection and financial security applications.

## ๐Ÿ”— Links

- ๐Ÿค— Model: https://huggingface.co/Pnny13/fraud-detection-model
- ๐Ÿš€ Space: https://huggingface.co/spaces/Pnny13/fraud-detection-space
- ๐Ÿ“Š Dataset: https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud

<p align="center">
<sub>Built with ๐Ÿ”ฅ by Death Legion | Best Teams Elite Division</sub>
</p>