A high-performance fraud detection system leveraging Random Forest and K-Medoids Clustering to analyze transaction patterns. Built with FastAPI and a Cyberpunk-inspired terminal UI.
bankfraudML/
├── .venv/ # Virtual environment
├── app/
│ ├── models/ # Trained .pkl model files
│ ├── main.py # FastAPI application & routes
│ └── modelProcess.py # ML logic & Feature engineering
├── static/
│ └── css/ # im lazy so I didn't use it
├── templates/
│ └── index.html # Terminal UI
├── bank_data.db # SQLite database
├── dataPre.py # Data initialization script
└── requirements.txt # Project dependencies
- Python: 3.11.x (Strictly preferred)
- OS: Windows (Command usage optimized for PowerShell)
Activate the virtual environment to ensure all dependencies are isolated.
# In Windows PowerShell
& ./.venv/Scripts/Activate.ps1Install the necessary ML and Web frameworks:
pip install -r requirements.txtYou must run the preprocessing script first to initialize the SQLite database and prepare the lookup tables for the models.
python dataPre.pyStart the FastAPI server. The entry point is located in the app directory.
uvicorn app.main:app --reloadOnce the server is live at http://127.0.0.1:8000:
- Terminal UI: Access the interactive dashboard via your browser.
- REST Endpoint: Send
POSTrequests to/predictwith the following JSON shape:
{
"step": 179,
"customer": "C1234567",
"age": 3,
"gender": "M",
"merchant": "M1823072687",
"category": "food",
"amount": 150.00
}This is just my own archived version of my works in the unit COS30049 - Innovation Tech Project at Swinburne Vietnam. This is one of the earliest ML product in my IT career. Hope I can get far in this journey:)