tests/testthat/test_unicode.R

context("Test Unicode handling")

data(agaricus.train, package = 'xgboost')
data(agaricus.test, package = 'xgboost')
train <- agaricus.train
test <- agaricus.test
set.seed(1994)

test_that("Can save and load models with Unicode paths", {
  nrounds <- 2
  bst <- xgb.train(
    data = xgb.DMatrix(train$data, label = train$label, nthread = 1),
    nrounds = nrounds,
    params = xgb.params(
      max_depth = 2,
      nthread = 2,
      objective = "binary:logistic"
    )
  )
  tmpdir <- tempdir()
  lapply(c("모델.json", "がうる・ぐら.json", "类继承.ubj"), function(x) {
    path <- file.path(tmpdir, x)
    xgb.save(bst, path)
    bst2 <- xgb.load(path)
    xgb.model.parameters(bst2) <- list(nthread = 2)
    expect_equal(predict(bst, test$data), predict(bst2, test$data))
  })
})

Try the xgboost package in your browser

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

xgboost documentation built on Dec. 3, 2025, 5:06 p.m.