Exercise

Trees for defaults

You will now train a gradient boosted tree model on the credit data, and see a sample of some of the predictions. Do you remember when you first looked at the predictions of the logistic regression model? They didn't look good. Do you think this model be different?

The credit data cr_loan_prep, the training sets X_train and y_train, and the test data X_test is available in the workspace. The XGBoost package is loaded as xgb.

Instructions

100 XP
  • Create and train a gradient boosted tree using XGBClassifier() and name it clf_gbt.
  • Predict probabilities of default on the test data and store the results in gbt_preds.
  • Create two data frames, preds_df and true_df, to store the first five predictions and true loan_status values.
  • Concatenate and print the data frames true_df and preds_df in order, and check the model's results.