Credit Risk Prediction using Ensemble Learning
This project aims to predict the probability of credit default using a combination of Logistic Regression, Random Forest, and XGBoost classifiers combined in a soft voting ensemble. The dataset contains financial, demographic, and credit history attributes of loan applicants. The objective is to identify high-risk applicants and support better lending decisions.
Dataset
Source: Give Me Some Credit.csv
Target variable: SeriousDlqin2yrs
0β No serious delinquency in the past 2 years1β Serious delinquency occurred
Key Features:
RevolvingUtilizationOfUnsecuredLinesβ Ratio of credit card balance to credit limitNumberOfTime30-59DaysPastDueNotWorseβ Count of 30-59 days late paymentsageβ Age of the applicantNumberOfTimes90DaysLateβ Count of 90+ days late paymentsDebtRatioβ Monthly debt payments to income ratioMonthlyIncomeβ Monthly income of the applicantNumberOfOpenCreditLinesAndLoansβ Number of open credit lines and loans- ...and other relevant credit-related attributes.
Data Preprocessing
Handling Missing Values: Median imputation for numerical columns.
Outlier Treatment: Clipping based on IQR method.
Feature Engineering:
DebtToIncomeRatio=RevolvingUtilizationOfUnsecuredLines / MonthlyIncome- Age binning into categories (
<30,30-40,40-50,50-60,60+)
Scaling: StandardScaler applied to numerical features.
Class Imbalance Handling: Stratified train-test split to maintain target distribution.
Model Training
Three base models were trained and tuned using GridSearchCV with ROC-AUC as the scoring metric:
- Logistic Regression (with L1 regularization)
- Random Forest Classifier
- XGBoost Classifier
These were combined into a VotingClassifier with voting="soft" to leverage predicted probabilities from all models.
Model Performance
| Metric | Class 0 | Class 1 |
|---|---|---|
| Precision | 0.94 | 0.60 |
| Recall | 0.99 | 0.18 |
| F1-Score | 0.97 | 0.28 |
| Accuracy | 0.94 | |
| ROC-AUC Score | 0.864 |
Macro Avg F1: 0.62 Weighted Avg F1: 0.92
Feature Importance (SHAP Analysis)
The top features influencing the modelβs predictions are:
- RevolvingUtilizationOfUnsecuredLines
- NumberOfTime30-59DaysPastDueNotWorse
- Age
- NumberOfTimes90DaysLate
- NumberOfOpenCreditLinesAndLoans
- DebtToIncomeRatio
π Conclusion
- The ensemble approach achieved a ROC-AUC of ~0.864, showing strong discriminatory power.
- SHAP analysis highlighted that credit utilization, late payment history, and age are key determinants of credit risk.