Our client would like us to use machine learning to predict credit risk for peer-to-peer loans. For the analysis we created models using six different methods and ran statistical results on the models to help us determine if there is a model that works better to help predict credit risk.
The analysis was conducted using Python and the following components:
- Pandas
- Scikit-learn
- Imbalanced-learn
The initial data was preprocessed by performing the following steps:
- the null columns where all values are null were dropped
- the null rows were dropped
- the loan status of "Issued" was removed
- the interest rate was converted to a numerical data type
- the target column was classified at low risk or high risk based on the how late the loan was
- the training variables were created from string data types to numerical data types using the get dummies method
- the target variables were created
After the initial preprocessing of the data was performed six models were created for different methods. The different methods used were:
- Oversampling
- Undersampling
- Combination (Over and Under) Sampling
- Ensemble Learning
The first model run for the Oversampling method was a Native Random Oversampling model.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The second model run for the Oversampling method was a SMOTE Oversampling model.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The third model run was an Undersampling model.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The forth model run was the SMOTEENN model of the Comination (Over and Under) Sampling method.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The fifth model model run was the Balanced Random Forest Classifier model of the Ensemble Classifiers method.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The final model run was also from the Ensemble Classifiers method and it was the Easy Ensemble AdaBoost Classifier.
The balanced accuracy score for this model is shown below:
The classification report showing precision and recall scores for this model is shown below:
The different models provided different results and many of them were quite similar, however the Ensemble Classifiers had a much higher balance accuracy score. Looking at the results of the models the recommended model to use would be the Easy Ensemble AdaBoost Classifier model. In addition to a high balanced accuracy score this model also had precision and recall scores that were substantiall higher than for other models.