Prints formatted results of xgb.cv().
Usage
# S3 method for class 'xgb.cv.synchronous'
print(x, verbose = FALSE, ...)Details
When not verbose, it would only print the evaluation results, including the best iteration (when available).
Examples
data(agaricus.train, package = "xgboost")
train <- agaricus.train
cv <- xgb.cv(
data = xgb.DMatrix(train$data, label = train$label, nthread = 1),
nfold = 5,
nrounds = 2,
params = xgb.params(
max_depth = 2,
nthread = 2,
objective = "binary:logistic"
)
)
#> [1] train-logloss:0.482039±0.000741 test-logloss:0.482209±0.001673
#> [2] train-logloss:0.359304±0.000751 test-logloss:0.359445±0.001502
print(cv)
#> ##### xgb.cv 5-folds
#> iter train_logloss_mean train_logloss_std test_logloss_mean test_logloss_std
#> <int> <num> <num> <num> <num>
#> 1 0.4820394 0.0007411453 0.4822088 0.001672725
#> 2 0.3593041 0.0007513172 0.3594447 0.001502428
print(cv, verbose = TRUE)
#> ##### xgb.cv 5-folds
#> call:
#> xgb.cv(params = xgb.params(max_depth = 2, nthread = 2, objective = "binary:logistic"),
#> data = xgb.DMatrix(train$data, label = train$label, nthread = 1),
#> nrounds = 2, nfold = 5)
#> params (as set within xgb.cv):
#> objective = "binary:logistic", nthread = "2", max_depth = "2", silent = "1"
#> evaluation_log:
#> iter train_logloss_mean train_logloss_std test_logloss_mean test_logloss_std
#> <int> <num> <num> <num> <num>
#> 1 0.4820394 0.0007411453 0.4822088 0.001672725
#> 2 0.3593041 0.0007513172 0.3594447 0.001502428