|
22 | 22 | #' data(agaricus.train) |
23 | 23 | #' data(agaricus.test) |
24 | 24 | #' |
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 | +#' } |
28 | 34 | #' |
29 | 35 | #' xgb_bundle <- bundle(xgb) |
30 | 36 | #' |
@@ -56,7 +62,7 @@ bundle.xgb.Booster <- function(x, ...) { |
56 | 62 | attr(res, "feature_names") <- !!attr(x, "feature_names") |
57 | 63 | } else { |
58 | 64 | res <- xgboost::xgb.load.raw(object, as_booster = TRUE) |
59 | | - |
| 65 | + |
60 | 66 | res$params <- list( |
61 | 67 | objective = !!x$params$objective, |
62 | 68 | num_class = !!x$params$num_class |
|
0 commit comments