cb.cv.predict {xgboost} | R Documentation

## Callback closure for returning cross-validation based predictions.

### Description

Callback closure for returning cross-validation based predictions.

### Usage

    cb.cv.predict(save_models = FALSE)

### Arguments

`save_models` | a flag for whether to save the folds' models.

### Details

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

It is a "finalizer" callback and it uses early stopping information whenever it is available, thus it must be run after the early stopping callback if the early stopping is used.

Callback function expects the following values to be set in its calling frame: `bst_folds`, `basket`, `data`, `end_iteration`, `params`, `num_parallel_tree`, `num_class`.

### Value

Predictions are returned 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`.

### See Also

`callbacks`

[Package xgboost version 0.90.0.2 Index]