Detecting fraudulent transactions using advanced machine learning models: RandomForest and LightGBM.
This project demonstrates end-to-end data preprocessing, feature engineering, model training, evaluation, and visualization.
- Features
- Project Structure
- Installation
- Usage
- Visual Results
- Future Improvements
- Contributing
- Author
✅ Data cleaning (handling duplicates & missing values)
✅ One-hot encoding for categorical variables
✅ Scaled numerical features for better model performance
✅ Two models compared: RandomForest (robust) & LightGBM (fast)
✅ Performance evaluation: Confusion Matrix, ROC-AUC, Precision-Recall, Feature Importance
✅ Ready-to-use saved models (.pkl) and generated plots (.png)
fraud-detection/ │ ├── fraud_detection.py # Main Python script ├── rf_model.pkl # Saved RandomForest model ├── lgb_model.pkl # Saved LightGBM model ├── rf_confusion.png # Confusion Matrix plot ├── rf_roc.png # ROC Curve ├── rf_pr.png # Precision-Recall Curve ├── rf_feature_importance.png # Feature Importance └── README.md # This file
- Clone the repository:
git clone https://github.com/ShreyanshDubey09/fraud-detection.git cd fraud-detection
pip install pandas numpy matplotlib seaborn scikit-learn lightgbm joblib
Usage
-
Place your Fraud.csv dataset in the working directory or update the path in fraud_detection.py.
-
Run the script:
from google.colab import drive drive.mount('/content/drive')
- Implement SMOTE or undersampling for extreme class imbalance
- Deploy as a REST API using FastAPI or Flask
- Experiment with deep learning models (e.g., LSTM or Autoencoder)
- Add hyperparameter tuning (e.g., GridSearchCV, Optuna)
Pull requests are welcome! For major changes, open an issue first to discuss what you’d like to change.
If you find this project helpful, please ⭐ the repo — it means a lot!
👩💻 Author Shreyansh Dubey
🌐 Portfolio - https://shreyanshdubey09.github.io/shreyansh-dubey.github.io/
💼 LinkedIn - https://www.linkedin.com/in/shreyanshdubey/
🐙 GitHub - https://github.com/ShreyanshDubey09
✉️ Email: sdubey0009999@gmail.com
