[R] maintenance Apr 2017 (#2237)
* [R] make sure things work for a single split model; fixes #2191 * [R] add option use_int_id to xgb.model.dt.tree * [R] add example of exporting tree plot to a file * [R] set save_period = NULL as default in xgboost() to be the same as in xgb.train; fixes #2182 * [R] it's a good practice after CRAN releases to bump up package version in dev * [R] allow xgb.DMatrix construction from integer dense matrices * [R] xgb.DMatrix: silent parameter; improve documentation * [R] xgb.model.dt.tree code style changes * [R] update NEWS with parameter changes * [R] code safety & style; handle non-strict matrix and inherited classes of input and model; fixes #2242 * [R] change to x.y.z.p R-package versioning scheme and set version to 0.6.4.3 * [R] add an R package versioning section to the contributors guide * [R] R-package/README.md: clean up the redundant old installation instructions, link the contributors guide
This commit is contained in:
committed by
Tong He
parent
d769b6bcb5
commit
a375ad2822
@@ -133,6 +133,12 @@ test_that("xgb.model.dt.tree works with and without feature names", {
|
||||
dt.tree.x <- xgb.model.dt.tree(model = bst.Tree.x)
|
||||
expect_output(str(dt.tree.x), 'Feature.*\\"3\\"')
|
||||
expect_equal(dt.tree[, -4, with=FALSE], dt.tree.x[, -4, with=FALSE])
|
||||
|
||||
# using integer node ID instead of character
|
||||
dt.tree.int <- xgb.model.dt.tree(model = bst.Tree, use_int_id = TRUE)
|
||||
expect_equal(as.integer(tstrsplit(dt.tree$Yes, '-')[[2]]), dt.tree.int$Yes)
|
||||
expect_equal(as.integer(tstrsplit(dt.tree$No, '-')[[2]]), dt.tree.int$No)
|
||||
expect_equal(as.integer(tstrsplit(dt.tree$Missing, '-')[[2]]), dt.tree.int$Missing)
|
||||
})
|
||||
|
||||
test_that("xgb.model.dt.tree throws error for gblinear", {
|
||||
@@ -169,6 +175,17 @@ test_that("xgb.importance works with GLM model", {
|
||||
xgb.ggplot.importance(importance.GLM)
|
||||
})
|
||||
|
||||
test_that("xgb.model.dt.tree and xgb.importance work with a single split model", {
|
||||
bst1 <- xgboost(data = sparse_matrix, label = label, max_depth = 1,
|
||||
eta = 1, nthread = 2, nrounds = 1, verbose = 0,
|
||||
objective = "binary:logistic")
|
||||
expect_error(dt <- xgb.model.dt.tree(model = bst1), regexp = NA) # no error
|
||||
expect_equal(nrow(dt), 3)
|
||||
expect_error(imp <- xgb.importance(model = bst1), regexp = NA) # no error
|
||||
expect_equal(nrow(imp), 1)
|
||||
expect_equal(imp$Gain, 1)
|
||||
})
|
||||
|
||||
test_that("xgb.plot.tree works with and without feature names", {
|
||||
xgb.plot.tree(feature_names = feature.names, model = bst.Tree)
|
||||
xgb.plot.tree(model = bst.Tree)
|
||||
|
||||
Reference in New Issue
Block a user