Skip to contents

This callback function saves predictions for all of the test folds, and also allows to save the folds' models.

Usage

xgb.cb.cv.predict(save_models = FALSE, outputmargin = FALSE)

Arguments

save_models

A flag for whether to save the folds' models.

outputmargin

Whether to save margin predictions (same effect as passing this parameter to predict.xgb.Booster).

Value

An xgb.Callback object, which can be passed to xgb.cv(), but not to xgb.train().

Details

Predictions are saved inside of the pred element, which is either a vector or a matrix, depending on the number of prediction outputs per data row. The order of predictions corresponds to the order of rows in the original dataset. Note that when a custom folds list is provided in xgb.cv(), the predictions would only be returned properly when this list is a non-overlapping list of k sets of indices, as in a standard k-fold CV. The predictions would not be meaningful when user-provided folds have overlapping indices as in, e.g., random sampling splits. When some of the indices in the training dataset are not included into user-provided folds, their prediction value would be NA.