Exercise

Cross validating credit models

Credit loans and their data change over time, and it won't always look like what's been loaded into the current test sets. So, you can use cross-validation to try several smaller training and test sets which are derived from the original X_train and y_train.

Use the XGBoost function cv() to perform cross-validation. You will need to set up all the parameters for cv() to use on the test data.

The data sets X_train, y_train are loaded in the workspace along with the trained model gbt, and the parameter dictionary params which will print once the exercise loads.

Instructions

100 XP
  • Set the number of folds to 5 and the stopping to 10. Store them as n_folds and early_stopping.
  • Create the matrix object DTrain using the training data.
  • Use cv() on the parameters, folds, and early stopping objects. Store the results as cv_df.
  • Print the contents of cv_df.