An end-to-end Machine Learning solution designed to predict loan default risks using financial and demographic customer data.
This project addresses the critical challenge of credit risk assessment in the financial sector. Using a dataset of over 250,000 records, I developed a robust predictive model that identifies potential loan defaulters with high precision.
The project transitions from a comprehensive exploratory analysis in a Jupyter Notebook to a production-ready interactive application deployed using Streamlit.
The solution enables financial institutions to automate risk assessment, improve lending decisions, and reduce exposure to high-risk borrowers.
🔗 Access the Credit Risk Predictor App
https://credit-risk-prediction-jffbjcq2ddxayyumemx86l.streamlit.app/
- Python
- Pandas
- NumPy
- Scikit-Learn
- XGBoost
- Logistic Regression
- Random Forest
- Matplotlib
- Seaborn
- Plotly
- Streamlit
- GitHub
- Removed non-informative columns such as
LoanID - Handled missing values and inconsistencies
- Converted binary categories:
HasMortgageHasDependentsHasCoSigner
into numerical representations.
- Applied feature preprocessing for categorical and numerical variables.
Performed extensive analysis to understand:
- Loan default behavior
- Correlations between variables
- Risk-driving financial indicators
- Customer demographic trends
Visualizations were created to identify:
- Income distributions
- Credit score patterns
- Interest rate impacts
- Loan amount relationships
Multiple machine learning models were tested and evaluated.
Used as the baseline classification model.
Implemented to capture non-linear feature interactions.
Chosen due to superior predictive performance and robustness on imbalanced data.
Key optimization techniques:
- Hyperparameter tuning
scale_pos_weighthandling- Feature preprocessing
- Threshold tuning
The project focused on metrics that are highly important in credit risk systems:
- Recall
- Precision
- F1 Score
- accuracy score
- confusion matrix
Special emphasis was placed on Recall to minimize false negatives and ensure high-risk borrowers are properly identified.
An interactive web application was developed using Streamlit to make the model accessible to end users.
Predict whether an individual customer is likely to default.
Upload a CSV file containing multiple customers for bulk risk analysis.
Displays the probability of default for each applicant.
Provides analytics and visual insights into the dataset.
Users can export prediction results as CSV files.
Clean dashboard layout suitable for business presentations and demonstrations.
The analysis revealed several important drivers of loan default risk.
- Lower credit scores significantly increase default probability.
- High interest rates correlate strongly with loan defaults.
- Lower income levels increase financial vulnerability.
- Employment instability is a strong predictor of repayment challenges.
- Higher loan amounts increase lending exposure.
This system can help financial institutions:
- Automate initial loan screening
- Reduce manual risk assessment workload
- Improve decision consistency
- Minimize credit losses
- Accelerate loan approval workflows
- Support data-driven lending strategies
ML PROJECTS/
│
├── credit_risk_prediction.ipynb # Research, EDA, and model experimentation
├── Loan_default.csv # Dataset
├── train_model.py # Model training pipeline
├── app.py # Streamlit application
├── model.pkl # Trained machine learning model
├── preprocessor.pkl # Saved preprocessing pipeline
├── requirements.txt # Python dependencies
└── README.md # Project documentation
git clone https://github.com/BrentOchieng/Credit-Risk-Prediction.gitcd Credit-Risk-Predictionpip install -r requirements.txtpython train_model.pyThis generates:
model.pkl
preprocessor.pkl
streamlit run app.pyhttp://localhost:8501
The application can be deployed using:
- Streamlit Community Cloud
- Render
- Railway
- AWS
- Azure
Potential future enhancements include:
- SHAP explainability integration
- User authentication system
- Real-time database integration
- Cloud API deployment
- Automated model retraining
- Advanced monitoring dashboards