Skip to content

Commit 33a0296

Browse files
[backport][R] Correct docs about attributes of cv object (dmlc#11732) (dmlc#11737)
Co-authored-by: david-cortes <[email protected]>
1 parent cb02c22 commit 33a0296

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

R-package/R/xgb.cv.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676
#' - `nfeatures`: Number of features in training data.
7777
#' - `folds`: The list of CV folds' indices - either those passed through the `folds`
7878
#' parameter or randomly generated.
79-
#' - `best_iteration`: Iteration number with the best evaluation metric value
80-
#' (only available with early stopping).
8179
#'
8280
#' Plus other potential elements that are the result of callbacks, such as a list `cv_predict` with
8381
#' a sub-element `pred` when passing `prediction = TRUE`, which is added by the [xgb.cb.cv.predict()]
@@ -92,18 +90,23 @@
9290
#'
9391
#' cv <- xgb.cv(
9492
#' data = dtrain,
95-
#' nrounds = 3,
93+
#' nrounds = 20,
94+
#' early_stopping_rounds = 1,
9695
#' params = xgb.params(
9796
#' nthread = 2,
9897
#' max_depth = 3,
9998
#' objective = "binary:logistic"
10099
#' ),
101100
#' nfold = 5,
102-
#' metrics = list("rmse","auc")
101+
#' metrics = list("rmse","auc"),
102+
#' prediction = TRUE
103103
#' )
104104
#' print(cv)
105105
#' print(cv, verbose = TRUE)
106106
#'
107+
#' # Callbacks might add additional attributes, separated by the name of the callback
108+
#' cv$early_stop$best_iteration
109+
#' head(cv$cv_predict$pred)
107110
#' @export
108111
xgb.cv <- function(params = xgb.params(), data, nrounds, nfold,
109112
prediction = FALSE, showsd = TRUE, metrics = list(),

R-package/man/xgb.cv.Rd

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)