[R-package] GPL2 dependency reduction and some fixes (#1401)
* [R] do not remove zero coefficients from gblinear dump * [R] switch from stringr to stringi * fix #1399 * [R] separate ggplot backend, add base r graphics, cleanup, more plots, tests * add missing include in amalgamation - fixes building R package in linux * add forgotten file * [R] fix DESCRIPTION * [R] fix travis check issue and some cleanup
This commit is contained in:
committed by
Tong He
parent
f6423056c0
commit
d5c143367d
@@ -24,12 +24,22 @@ feature.names <- colnames(sparse_matrix)
|
||||
|
||||
test_that("xgb.dump works", {
|
||||
expect_length(xgb.dump(bst.Tree), 172)
|
||||
expect_length(xgb.dump(bst.GLM), 14)
|
||||
expect_true(xgb.dump(bst.Tree, 'xgb.model.dump', with_stats = T))
|
||||
expect_true(file.exists('xgb.model.dump'))
|
||||
expect_gt(file.size('xgb.model.dump'), 8000)
|
||||
})
|
||||
|
||||
test_that("xgb.dump works for gblinear", {
|
||||
expect_length(xgb.dump(bst.GLM), 14)
|
||||
# also make sure that it works properly for a sparse model where some coefficients
|
||||
# are 0 from setting large L1 regularization:
|
||||
bst.GLM.sp <- xgboost(data = sparse_matrix, label = label, eta = 1, nthread = 2, nrounds = 1,
|
||||
alpha=2, objective = "binary:logistic", booster = "gblinear")
|
||||
d.sp <- xgb.dump(bst.GLM.sp)
|
||||
expect_length(d.sp, 14)
|
||||
expect_gt(sum(d.sp == "0"), 0)
|
||||
})
|
||||
|
||||
test_that("xgb-attribute functionality", {
|
||||
val <- "my attribute value"
|
||||
list.val <- list(my_attr=val, a=123, b='ok')
|
||||
@@ -76,7 +86,9 @@ test_that("xgb.importance works with and without feature names", {
|
||||
expect_equal(dim(importance.Tree), c(7, 4))
|
||||
expect_equal(colnames(importance.Tree), c("Feature", "Gain", "Cover", "Frequency"))
|
||||
expect_output(str(xgb.importance(model = bst.Tree)), 'Feature.*\\"3\\"')
|
||||
xgb.plot.importance(importance_matrix = importance.Tree)
|
||||
imp2plot <- xgb.plot.importance(importance_matrix = importance.Tree)
|
||||
expect_equal(colnames(imp2plot), c("Feature", "Gain", "Cover", "Frequency", "Importance"))
|
||||
xgb.ggplot.importance(importance_matrix = importance.Tree)
|
||||
})
|
||||
|
||||
test_that("xgb.importance works with GLM model", {
|
||||
@@ -84,7 +96,9 @@ test_that("xgb.importance works with GLM model", {
|
||||
expect_equal(dim(importance.GLM), c(10, 2))
|
||||
expect_equal(colnames(importance.GLM), c("Feature", "Weight"))
|
||||
xgb.importance(model = bst.GLM)
|
||||
xgb.plot.importance(importance.GLM)
|
||||
imp2plot <- xgb.plot.importance(importance.GLM)
|
||||
expect_equal(colnames(imp2plot), c("Feature", "Weight", "Importance"))
|
||||
xgb.ggplot.importance(importance.GLM)
|
||||
})
|
||||
|
||||
test_that("xgb.plot.tree works with and without feature names", {
|
||||
@@ -98,7 +112,10 @@ test_that("xgb.plot.multi.trees works with and without feature names", {
|
||||
})
|
||||
|
||||
test_that("xgb.plot.deepness works", {
|
||||
xgb.plot.deepness(model = bst.Tree)
|
||||
d2p <- xgb.plot.deepness(model = bst.Tree)
|
||||
expect_equal(colnames(d2p), c("ID", "Tree", "Depth", "Cover", "Weight"))
|
||||
xgb.plot.deepness(model = bst.Tree, which = "med.depth")
|
||||
xgb.ggplot.deepness(model = bst.Tree)
|
||||
})
|
||||
|
||||
test_that("check.deprecation works", {
|
||||
|
||||
Reference in New Issue
Block a user