bharath-inamdar/fraud-detection-api

GitHub: bharath-inamdar/fraud-detection-api

一个基于 FastAPI 与机器学习的实时信用卡欺诈检测系统,解决高不平衡数据下的精准识别问题。

Stars: 0 | Forks: 0

# 欺诈检测 API 基于 FastAPI 和机器学习的实时信用卡欺诈检测系统。 ## 🚀 实时演示 👉 [实时仪表板](https://fraud-detection-api-xeh8.onrender.com/static/index.html) 👉 [API 文档](https://fraud-detection-api-xeh8.onrender.com/docs) ## 数据集 - 来自 Kaggle 信用卡欺诈检测数据集的 284,807 笔交易 - 仅 492 起欺诈案例(0.17%)— 通过 SMOTE 处理严重类别不平衡 ## 工作原理 交易 → 规则引擎 → 机器学习模型 → 响应 **第一层 — 规则引擎**(即时决策): - 金额 > €10,000 → 自动拦截 - 金额无效 → 自动拦截 **第二层 — 机器学习模型**(智能评分): - 在 284k 笔交易上训练的随机森林 - 使用 SMOTE 过采样处理类别不平衡 - 返回欺诈概率分数(0.0 到 1.0) ## 模型性能 - 精确率:85% - 召回率:84% - 在测试集中捕获 98 起欺诈案例中的 82 起 ## 技术栈 - **后端:** FastAPI、Python - **机器学习:** Scikit-learn、XGBoost、imbalanced-learn - **数据:** Pandas、NumPy - **前端:** HTML、CSS、JavaScript ## 本地运行 ``` # 克隆仓库 git clone https://github.com/bharath-inamdar/fraud-detection-api.git cd fraud-detection-api # 创建虚拟环境 python -m venv venv venv\Scripts\activate # 安装依赖 pip install -r requirements.txt # 训练模型 python ml/train.py # 启动服务器 uvicorn app.main:app --reload ``` 然后打开 `http://127.0.0.1:8000/static/index.html` ## 📁 项目结构 fraud-detection-api/ ├── app/ │ ├── main.py # FastAPI 服务器 │ ├── models.py # 请求/响应结构 │ ├── predict.py # 机器学习预测逻辑 │ └── rules.py # 规则引擎 ├── ml/ │ ├── train.py # 模型训练脚本 ├── static/ │ └── index.html # 前端仪表板 └── requirements.txt ## 👤 作者 Bharath Inamdar — M.S. Ramaiah Institute of Technology
标签:Apex, API, AV绕过, CMS安全, CSS, DNS解析, FastAPI, HTML, imbalanced-learn, JavaScript, Kaggle, Python后端, Scikit-learn, SMOTE, TCP/UDP协议, XGBoost, 云计算, 交易数据, 交易评分, 信用卡欺诈, 前端仪表盘, 反欺诈系统, 召回率, 多模态安全, 实时欺诈检测, 开源项目, 性能评估, 数据可视化, 数据科学, 机器学习, 模型部署, 欺诈概率, 类别不平衡, 精准度, 规则引擎, 资源验证, 逆向工具, 金融科技, 随机森林, 预测分析