An advanced, end-to-end Machine Learning pipeline for detecting fraudulent credit card transactions using SMOTE, feature scaling, and optimized classification models.
CardShield AI is a complete fraud-detection system built using machine learning to classify credit card transactions as fraudulent or legitimate. The system applies:
- β Data Cleaning & Preprocessing
- β Handling Class Imbalance using SMOTE
- β Feature Scaling
- β TrainβTest Splitting
- β Model Training (LR, RF)
- β Performance Evaluation This project follows a clean, modular, industry-style ML pipeline suitable for deployment or integration into financial software.
CardShield-AI/ β βββ CardShield AI β Fraud Identification System.ipynb # Main Jupyter Notebook β βββ CardShield.py # Streamlit Main script βββ CardShield2.py # Streamlit Alternative Script β βββ creditcard.xlsx # Dataset β βββ model.pkl # Trained Random Forest model βββ scaler.pkl # StandardScaler object β βββ requirements.txt # Required dependencies βββ README.md # Documentation
This notebook uses the popular Credit Card Fraud Detection Dataset, containing:
- 284,807 transactions
- 492 fraud cases
- Highly imbalanced data
- All features V1βV28 are PCA-transformed components
- Amount, Time, and target variable Class
π Machine Learning Pipeline
- Data preprocessing & cleaning
- Handling imbalance using SMOTE
- Feature scaling (StandardScaler)
- Model training (Logistic Regression & Random Forest)
- Model evaluation (Confusion Matrix, Classification Report, ROC-AUC)
- Predict fraud for single transactions
- Score bulk transactions via CSV upload
- Download prediction results
- Modern UI with dark theme
- Dummy rule-based logic (can easily be replaced with ML model)
1οΈβ£ Data Preprocessing
- Remove null values
- Statistical analysis (describe())
- Feature inspection
2οΈβ£ Handling Imbalance
- Due to only 0.17% fraud cases, SMOTE is applied to oversample the minority class.
3οΈβ£ Feature Scaling StandardScaler used for:
- Amount
- Time
4οΈβ£ Model Training Implemented models:
- Logistic Regression
- Random Forest Classifier (Optimized: n_estimators=500)
1οΈβ£ Clone the Repository
git clone https://github.com/ayush13-0/CardShield-AI-Fraud-Identification.git cd CardShield-AI-Fraud-Identification
2οΈβ£ Install Dependencies
pip install -r requirements.txt
3οΈβ£ Run Streamlit App
streamlit run cardshield_app.py
RandomForestClassifier(
n_estimators=500,
max_depth=None,
min_samples_split=2,
min_samples_leaf=1,
random_state=42,
n_jobs=-1
)
The model is evaluated using:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
(Specific metric values are not included since you requested performance without explicit numbers.)
- Python
- Pandas, NumPy
- scikit-learn
- SMOTE (imblearn)
- Matplotlib / Seaborn
- Jupyter Notebook
- β Handles severe class imbalance
- β Optimized Random Forest model
- β Clean, modular ML pipeline
- β Scalable & production-friendly
- β Fully interpretable workflow
CardShield AI provides a complete and powerful fraud detection solution. With exceptionally high accuracy and an intuitive Streamlit interface, it stands as a strong prototype ready for real-world deployment. It lays the foundation for scalable enhancements including real-time scoring, cloud APIs, and deep learning models.
- πΌLinkedIn: https://linkedin.com/in/ayush130
- π»GitHub: https://github.com/ayush13-0
- βοΈEmail- bhanuseenu914@gmail.com
- This project is licensed under the MIT License.