An end-to-end machine learning project that classifies applicants into higher-risk and lower-risk categories using demographic, financial, employment, and historical credit information. The project explores multiple classification algorithms, handles imbalanced data, evaluates model performance, and deploys the final Random Forest model through an interactive Streamlit application.
The project uses two datasets:
application_record.csv– Applicant demographic, financial, and employment information.credit_record.csv– Historical credit repayment records.
The target variable, CREDIT_RISK, is engineered from historical credit statuses:
- 0 – Lower Risk: No observed severe delinquency status.
- 1 – Higher Risk: At least one historical status of 2, 3, 4, or 5.
The datasets are merged using the applicant ID.
- Python
- Pandas and NumPy
- Matplotlib and Seaborn
- Scikit-learn
- Imbalanced-learn
- XGBoost
- Joblib
- Streamlit
- Data loading and inspection
- Data cleaning and duplicate removal
- Exploratory Data Analysis (EDA)
- Feature engineering
- Missing-value imputation
- Categorical feature encoding using One-Hot Encoding
- Stratified train-test splitting
- Handling class imbalance
- Training and comparing classification models
- Hyperparameter tuning using RandomizedSearchCV
- Classification threshold experiments
- Feature importance and permutation importance analysis
- Model evaluation and Streamlit deployment
- Gaussian Naive Bayes
- Bagging Classifier with Gaussian Naive Bayes
- Decision Tree
- Random Forest
- Random Forest with SMOTE
- Random Forest with SMOTENC
- Tuned Random Forest
- XGBoost
The tuned Random Forest was selected based on its performance compared with the other experimental models.
Hyperparameters:
| Parameter | Value |
|---|---|
| n_estimators | 100 |
| max_depth | 12 |
| min_samples_split | 10 |
| min_samples_leaf | 10 |
| class_weight | balanced_subsample |
| Classification threshold | 0.5 |
Final evaluation on the held-out test dataset:
| Metric | Score |
|---|---|
| Accuracy | 96% |
| Precision (Class 1) | 0.14 |
| Recall (Class 1) | 0.30 |
| F1-score (Class 1) | 0.19 |
| ROC-AUC | 0.6934 |
| PR-AUC | 0.0959 |
PR-AUC was prioritised because the dataset contains a significant class imbalance.
The leading features identified by the Random Forest include:
- Employment years
- Age
- Annual income
- Number of family members
- Number of children
Permutation importance was also used to examine how individual features affect predictive performance.
An interactive Streamlit application allows users to enter applicant information and receive a predicted credit-risk classification.
The application uses the saved Random Forest model and preprocessing objects.
- Implementing multiple classification algorithms.
- Understanding class imbalance and its impact on model performance.
- Applying SMOTE and SMOTENC.
- Hyperparameter tuning with RandomizedSearchCV.
- Understanding precision, recall, F1-score, ROC-AUC, and PR-AUC.
- Classification threshold selection.
- Feature importance and model interpretation.
- Saving and deploying machine learning models.
- The target is an engineered proxy derived from historical credit statuses, not actual bank loan approval outcomes.
- The dataset is highly imbalanced.
- The final model has limited precision and recall for the higher-risk class.
- Feature importance does not establish causation.
- The model has not been validated for real-world lending decisions.