This is a Python-based machine learning project that detects fraudulent credit card transactions.
Before starting, ensure you have Python 3 installed on your computer.
If you are copying this project to a new computer (or presenting it), follow these exact steps to set it up from scratch:
Open a terminal (or Command Prompt) and navigate to the root directory of this project.
Install all the necessary libraries by running:
pip install -r requirements.txt(If you are on a modern Linux system like Ubuntu and get an "externally-managed-environment" error, run pip install --break-system-packages -r requirements.txt instead).
- Go to Kaggle: Credit Card Fraud Detection Dataset.
- Download and extract the ZIP file.
- Move the extracted
creditcard.csvfile into thedata/folder inside this project directory (data/creditcard.csv).
Before you can make predictions, you must train the machine learning model.
python3 src/train_model.pyThis script will:
- Load and balance the highly imbalanced dataset.
- Train the Logistic Regression algorithm.
- Save the model's "brain", scaler, and baseline features into the
models/directory. - Generate a visual Confusion Matrix plot in the
notebooks/plots/folder.
Once the model is trained and saved, you can launch the live interactive terminal to showcase the project:
python3 src/predict.pyThis will launch a highly-styled CLI application where you can type in a transaction amount and time. The system will process it and instantly alert you if it is Legitimate or Fraudulent!