Credit Risk Modeling in RStudio

Predicting Defaults on Credit Card Payments

This model will predict the probability that a credit card holder will default on their payment given their payment history and demographic information.

Import the numpy, pandas, xgboost, and scikit-learn packages:

Load data

Load the data and view its contents:

Split data into training and testing sets

Split the data set into 80% training and 20% testing portions:

Train model

Train the model using a binary classification algoritm:

Serialize model

Serialize the trained model to a file for later use:

Model Scoring

Generate model predictions on the test data and calculate the accuracy of the model:

Test model predictions

Let's generate a prediction for an account that we know has a good payment history:

Let's generate a prediction for an account that we know defaults on their payment: