| 1 |
context("Test Unicode handling") |
| 2 |
|
| 3 |
data(agaricus.train, package = 'xgboost') |
| 4 |
data(agaricus.test, package = 'xgboost') |
| 5 |
train <- agaricus.train |
| 6 |
test <- agaricus.test |
| 7 |
set.seed(1994) |
| 8 |
|
| 9 |
test_that("Can save and load models with Unicode paths", { |
| 10 |
nrounds <- 2 |
| 11 |
bst <- xgb.train( |
| 12 |
data = xgb.DMatrix(train$data, label = train$label, nthread = 1), |
| 13 |
nrounds = nrounds, |
| 14 |
params = xgb.params( |
| 15 |
max_depth = 2, |
| 16 |
nthread = 2, |
| 17 |
objective = "binary:logistic" |
| 18 |
) |
| 19 |
) |
| 20 |
tmpdir <- tempdir() |
| 21 |
lapply(c("모델.json", "がうる・ぐら.json", "类继承.ubj"), function(x) { |
| 22 |
path <- file.path(tmpdir, x) |
| 23 |
xgb.save(bst, path) |
| 24 |
bst2 <- xgb.load(path) |
| 25 |
xgb.model.parameters(bst2) <- list(nthread = 2) |
| 26 |
expect_equal(predict(bst, test$data), predict(bst2, test$data)) |
| 27 |
}) |
| 28 |
}) |