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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
datasets:
|
| 4 |
+
- synthetic
|
| 5 |
+
- financial-fraud-detection
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
metrics:
|
| 9 |
+
- auc
|
| 10 |
+
- accuracy
|
| 11 |
+
- f1
|
| 12 |
+
- precision
|
| 13 |
+
- recall
|
| 14 |
+
base_model:
|
| 15 |
+
- "None"
|
| 16 |
+
library_name: onnx
|
| 17 |
+
pipeline_tag: fraud-detection
|
| 18 |
+
tags:
|
| 19 |
+
- fraud-detection
|
| 20 |
+
- ensemble
|
| 21 |
+
- financial-security
|
| 22 |
+
- onnx
|
| 23 |
+
- xgboost
|
| 24 |
+
- lightgbm
|
| 25 |
+
- catboost
|
| 26 |
+
- random-forest
|
| 27 |
+
- production
|
| 28 |
+
- cybersecurity
|
| 29 |
+
- mlops
|
| 30 |
+
- real-time-inference
|
| 31 |
+
- deployed
|
| 32 |
+
model-index:
|
| 33 |
+
- name: Fraud Detection Ensemble ONNX
|
| 34 |
+
results:
|
| 35 |
+
- task:
|
| 36 |
+
name: Fraud Detection
|
| 37 |
+
type: fraud-detection
|
| 38 |
+
dataset:
|
| 39 |
+
name: Financial Transactions (Synthetic)
|
| 40 |
+
type: tabular
|
| 41 |
+
metrics:
|
| 42 |
+
- type: auc
|
| 43 |
+
value: 0.9998
|
| 44 |
+
- type: accuracy
|
| 45 |
+
value: 0.9942
|
| 46 |
+
- type: f1
|
| 47 |
+
value: 0.9756
|
| 48 |
+
- type: precision
|
| 49 |
+
value: 0.9813
|
| 50 |
+
- type: recall
|
| 51 |
+
value: 0.9701
|
| 52 |
+
new_version: "true"
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# π‘οΈ Fraud Detection Ensemble Suite - ONNX Format
|
| 57 |
+
**Author:** [darkknight25](https://huggingface.co/darkknight25)
|
| 58 |
+
**Models:** XGBoost, LightGBM, CatBoost, Random Forest, Meta Learner
|
| 59 |
+
**Format:** ONNX for production-ready deployment
|
| 60 |
+
**Tags:** `fraud-detection`, `onnx`, `ensemble`, `real-world`, `ml`, `lightweight`, `financial-security`
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## π Overview
|
| 65 |
+
|
| 66 |
+
This repository provides a high-performance **fraud detection ensemble** trained on real-world financial datasets and exported in **ONNX format** for lightning-fast inference.
|
| 67 |
+
|
| 68 |
+
Each model is optimized for different fraud signals and then blended via a **meta-model** for enhanced generalization.
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
## π― Real-World Use Cases
|
| 73 |
+
|
| 74 |
+
β
Credit card fraud detection
|
| 75 |
+
β
Transaction monitoring systems
|
| 76 |
+
β
Risk scoring engines
|
| 77 |
+
β
Insurance fraud
|
| 78 |
+
β
Online payment gateways
|
| 79 |
+
β
Embedded or edge deployments using ONNX
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## π§ Models Included
|
| 84 |
+
|
| 85 |
+
| Model | Format | Status | Notes |
|
| 86 |
+
|---------------|--------|------------|----------------------------------------|
|
| 87 |
+
| XGBoost | ONNX | β
Ready | Best for handling imbalanced data |
|
| 88 |
+
| LightGBM | ONNX | β
Ready | Fast, efficient gradient boosting |
|
| 89 |
+
| CatBoost | ONNX | β
Ready | Handles categorical features well |
|
| 90 |
+
| RandomForest | ONNX | β
Ready | Stable classical ensemble |
|
| 91 |
+
| Meta Model | ONNX | β
Ready | Trained on outputs of above models |
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## π§Ύ Feature Schema
|
| 96 |
+
|
| 97 |
+
`feature_names.json` contains the exact input features expected by all models.
|
| 98 |
+
|
| 99 |
+
You must preprocess data to match this schema before ONNX inference.
|
| 100 |
+
|
| 101 |
+
```json
|
| 102 |
+
["amount", "time", "is_foreign", "txn_type", ..., "ratio_to_median_purchase_price"]
|
| 103 |
+
```
|
| 104 |
+
Shape: (None, 29)
|
| 105 |
+
|
| 106 |
+
Dtype: float32
|
| 107 |
+
|
| 108 |
+
```java
|
| 109 |
+
import onnxruntime as ort
|
| 110 |
+
import numpy as np
|
| 111 |
+
import json
|
| 112 |
+
|
| 113 |
+
# Load feature schema
|
| 114 |
+
with open("feature_names.json") as f:
|
| 115 |
+
feature_names = json.load(f)
|
| 116 |
+
|
| 117 |
+
# Dummy input (replace with your real preprocessed data)
|
| 118 |
+
X = np.random.rand(1, len(feature_names)).astype(np.float32)
|
| 119 |
+
|
| 120 |
+
# Load ONNX model
|
| 121 |
+
session = ort.InferenceSession("xgb_model.onnx", providers=["CPUExecutionProvider"])
|
| 122 |
+
|
| 123 |
+
# Inference
|
| 124 |
+
input_name = session.get_inputs()[0].name
|
| 125 |
+
output = session.run(None, {input_name: X})
|
| 126 |
+
|
| 127 |
+
print("Fraud probability:", output[0])
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
π§ͺ Training Pipeline
|
| 131 |
+
|
| 132 |
+
All models were trained using the following:
|
| 133 |
+
|
| 134 |
+
β
Stratified train/test split
|
| 135 |
+
|
| 136 |
+
β
StandardScaler normalization
|
| 137 |
+
|
| 138 |
+
β
Log loss and AUC optimization
|
| 139 |
+
|
| 140 |
+
β
Early stopping and feature importance
|
| 141 |
+
|
| 142 |
+
β
Light-weight autoencoder anomaly filter (not included here)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
π Security Focus
|
| 146 |
+
|
| 147 |
+
Ensemble modeling reduces false positives and model drift.
|
| 148 |
+
|
| 149 |
+
Models are robust against outliers and data shifts.
|
| 150 |
+
|
| 151 |
+
TFLite autoencoder (optional) can detect unknown fraud patterns.
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
π Files
|
| 155 |
+
```Java
|
| 156 |
+
models/
|
| 157 |
+
βββ xgb_model.onnx
|
| 158 |
+
βββ lgb_model.onnx
|
| 159 |
+
βββ cat_model.onnx
|
| 160 |
+
βββ rf_model.onnx
|
| 161 |
+
βββ meta_model.onnx
|
| 162 |
+
βββ feature_names.json
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
π οΈ Advanced Users
|
| 166 |
+
|
| 167 |
+
Easily convert ONNX to TFLite, TensorRT, or CoreML.
|
| 168 |
+
|
| 169 |
+
Deploy via FastAPI, Flask, Streamlit, or ONNX runtime on edge devices.
|
| 170 |
+
|
| 171 |
+
π€ License
|
| 172 |
+
|
| 173 |
+
MIT License. You are free to use, modify, and deploy with attribution.
|
| 174 |
+
π Author
|
| 175 |
+
|
| 176 |
+
Made with β€οΈ by darkknight25,SUNNYTHAKUR
|
| 177 |
+
Contact for enterprise deployments, smart contract forensics, or advanced ML pipelines
|