| 1 |
context('Test model params and call are exposed to R') |
| 2 |
|
| 3 |
data(agaricus.train, package = 'xgboost') |
| 4 |
data(agaricus.test, package = 'xgboost') |
| 5 |
|
| 6 |
dtrain <- xgb.DMatrix( |
| 7 |
agaricus.train$data, label = agaricus.train$label, nthread = 2 |
| 8 |
) |
| 9 |
dtest <- xgb.DMatrix( |
| 10 |
agaricus.test$data, label = agaricus.test$label, nthread = 2 |
| 11 |
) |
| 12 |
|
| 13 |
bst <- xgb.train( |
| 14 |
data = dtrain, |
| 15 |
verbose = 0, |
| 16 |
nrounds = 10, |
| 17 |
params = xgb.params( |
| 18 |
max_depth = 2, |
| 19 |
learning_rate = 1, |
| 20 |
nthread = 1, |
| 21 |
objective = "binary:logistic" |
| 22 |
) |
| 23 |
) |
| 24 |
|
| 25 |
test_that("call is exposed to R", { |
| 26 |
expect_false(is.null(attributes(bst)$call)) |
| 27 |
expect_is(attributes(bst)$call, "call") |
| 28 |
}) |
| 29 |
|
| 30 |
test_that("params is exposed to R", { |
| 31 |
model_params <- attributes(bst)$params |
| 32 |
expect_is(model_params, "list") |
| 33 |
expect_equal(model_params$learning_rate, 1) |
| 34 |
expect_equal(model_params$max_depth, 2) |
| 35 |
expect_equal(model_params$objective, "binary:logistic") |
| 36 |
}) |