The Credit Card Default Prediction project leverages an Artificial Neural Network (ANN) to predict the likelihood of credit card defaults based on user input. It combines machine learning with a user-friendly interface to provide a robust solution for financial risk assessment. The project includes:
- A trained ANN model
- A FastAPI backend for API access
- A sleek, interactive Gradio web interface for predictions
- Machine Learning Model: Predict default risk using key financial and demographic data.
- Interactive Gradio Web Interface: An intuitive tool for making predictions in real-time.
- FastAPI Backend: Offers RESTful API endpoints for seamless integration.
- Comprehensive Input Features:
- Credit Limit
- Demographics (sex, education, marriage status, age)
- Past repayment status (6 months)
- Bill amounts (6 months)
- Payment amounts (6 months)
- Python: The backbone of this project
- TensorFlow/Keras: For building and training the ANN model
- FastAPI: RESTful API for backend services
- Gradio: Interactive web interface for predictions
- scikit-learn: Data preprocessing and performance metrics
- imbalanced-learn: Handling class imbalance
- NumPy & Pandas: Data manipulation and analysis
- Python 3.8+
- Conda package manager
git clone https://github.com/austinLorenzMccoy/credit-default-prediction.git
cd credit-default-prediction conda create -n credit-default python=3.11 -y
conda activate credit-default pip install -r requirements.txt - Data Cleaning & Preprocessing: Ensure quality inputs.
- Class Imbalance Handling: Applied RandomOverSampling for balanced training.
- Feature Scaling: Standardized inputs using
StandardScaler. - ANN Architecture:
- Input Layer: 64 neurons for input features
- Hidden Layers:
- Two dense layers with 32 neurons each
- Dropout layers for regularization
- Output Layer: Single neuron with Sigmoid activation for binary classification
- Training Optimization:
- Early Stopping to prevent overfitting
- TensorBoard Logging for tracking performance
uvicorn app:app --reload - FastAPI Backend: http://localhost:8000
- Gradio Interface: http://localhost:8002
- Gradio Interface: Use sliders and fields to input values and view predictions instantly.
- API Endpoint: Send a POST request to
/predictwith JSON payload for predictions.
{
"LIMIT_BAL": 200000,
"SEX": 1,
"EDUCATION": 2,
"MARRIAGE": 1,
"AGE": 30,
"PAY_0": 0,
"PAY_2": 0,
"PAY_3": -1,
"PAY_4": -1,
"PAY_5": 0,
"PAY_6": 0,
"BILL_AMT1": 50000,
"BILL_AMT2": 48000,
"BILL_AMT3": 47000,
"BILL_AMT4": 46000,
"BILL_AMT5": 45000,
"BILL_AMT6": 44000,
"PAY_AMT1": 5000,
"PAY_AMT2": 6000,
"PAY_AMT3": 7000,
"PAY_AMT4": 8000,
"PAY_AMT5": 9000,
"PAY_AMT6": 10000
} - Trained with early stopping for optimal performance
- Metrics visualized using TensorBoard and Matplotlib
- Training Logs: Access TensorBoard for real-time insights.
- Performance Metrics: Analyze accuracy and loss plots generated by Matplotlib.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to the branch:
git push origin feature/AmazingFeature
- Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
- Author: Austin Lorenz McCoy
- Email: chibuezeaugustine@gmail.com
- GitHub Repository: https://github.com/austinLorenzMccoy/credit-default-prediction