tests/testthat/test_gc_safety.R

require(xgboost)

context("Garbage Collection Safety Check")

test_that("train and prediction when gctorture is on", {
  data(agaricus.train, package = 'xgboost')
  data(agaricus.test, package = 'xgboost')
  train <- agaricus.train
  test <- agaricus.test
  gctorture(TRUE)
  bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
                 eta = 1, nthread = 2, nrounds = 2, objective = "binary:logistic")
  pred <- predict(bst, test$data)
  gctorture(FALSE)
  expect_length(pred, length(test$label))
})

Try the xgboost package in your browser

Any scripts or data that you put into this service are public.

xgboost documentation built on March 31, 2023, 10:05 p.m.