Skip to content

Commit 31d774e

Browse files
make xgboost example version switched (#78)
1 parent 0e428ab commit 31d774e

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

R/bundle_xgboost.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@
2222
#' data(agaricus.train)
2323
#' data(agaricus.test)
2424
#'
25-
#' xgb <- xgboost(data = agaricus.train$data, label = agaricus.train$label,
26-
#' max_depth = 2, eta = 1, nthread = 2, nrounds = 2,
27-
#' objective = "binary:logistic")
25+
#' if (utils::packageVersion("xgboost") >= "2.0.0.0") {
26+
#' xgb <- xgboost(x = agaricus.train$data, y = agaricus.train$label,
27+
#' max_depth = 2, learning_rate = 1, nthread = 2, nrounds = 2,
28+
#' objective = "reg:squarederror")
29+
#' } else {
30+
#' xgb <- xgboost(data = agaricus.train$data, label = agaricus.train$label,
31+
#' max_depth = 2, eta = 1, nthread = 2, nrounds = 2,
32+
#' objective = "binary:logistic")
33+
#' }
2834
#'
2935
#' xgb_bundle <- bundle(xgb)
3036
#'
@@ -56,7 +62,7 @@ bundle.xgb.Booster <- function(x, ...) {
5662
attr(res, "feature_names") <- !!attr(x, "feature_names")
5763
} else {
5864
res <- xgboost::xgb.load.raw(object, as_booster = TRUE)
59-
65+
6066
res$params <- list(
6167
objective = !!x$params$objective,
6268
num_class = !!x$params$num_class

man/bundle_xgboost.Rd

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

0 commit comments

Comments
 (0)