Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fraud-Scanner

Anomaly detection API for transaction scoring. Exposes a FastAPI service that returns a fraud probability and binary prediction from a JSON payload (e.g. Time, Amount, Hour).

Requirements

  • Python 3.11+
  • Or Docker

Setup

pip install -r requirements.txt

Run locally

uvicorn api.main:app --host 127.0.0.1 --port 8000

Then open http://127.0.0.1:8000/docs for the interactive API docs.

Run with Docker

From the project root:

docker build -t fraud-scanner .
docker run -p 8000:8000 fraud-scanner

The API is available at http://localhost:8000.

API

Method Path Description
GET /health Health check → {"status":"ok"}
POST /predict Score a transaction (JSON body)

Example /predict request:

{ "Time": 0.0, "Amount": 100.0, "Hour": 14 }

Example response:

{
  "prob": 0.23,
  "pred": 0,
  "threshold": 0.5,
  "missing_features": []
}
  • prob: fraud probability (0–1)
  • pred: 1 if fraud, 0 otherwise (based on threshold)
  • missing_features: list of expected features not sent (filled with 0.0)

Tests

pytest

Model

  • If models/best_model.joblib exists, it is loaded at startup (must contain model, threshold, features).
  • If not, a small default logistic regression model is created and saved so the API runs out of the box. Replace models/best_model.joblib with your own trained bundle when ready.

Project layout

  • api/main.py — FastAPI app and /health, /predict
  • src/ — training and scoring scripts (train_rf.py, batch_score.py, etc.)
  • tests/ — API and smoke tests
  • notebooks/ — EDA and exploration

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages