Add new tests for new functions

This commit is contained in:
pommedeterresautee
2015-11-30 15:04:17 +01:00
parent 376ba6912e
commit c09c02300a
5 changed files with 33 additions and 26 deletions

View File

@@ -19,15 +19,23 @@ bst <- xgboost(data = sparse_matrix, label = output_vector, max.depth = 9,
test_that("xgb.dump works", {
capture.output(print(xgb.dump(bst)))
expect_true(xgb.dump(bst, 'xgb.model.dump', with.stats = T))
})
test_that("xgb.importance works", {
expect_true(xgb.dump(bst, 'xgb.model.dump', with.stats = T))
importance <- xgb.importance(sparse_matrix@Dimnames[[2]], model = bst)
expect_equal(dim(importance), c(7, 4))
expect_equal(colnames(importance), c("Feature", "Gain", "Cover", "Frequency"))
})
test_that("xgb.plot.tree works", {
xgb.plot.tree(agaricus.train$data@Dimnames[[2]], model = bst)
xgb.plot.tree(names = agaricus.train$data@Dimnames[[2]], model = bst)
})
test_that("xgb.plot.deepness works", {
xgb.plot.deepness(model = bst)
})
test_that("xgb.plot.multi.trees works", {
xgb.plot.multi.trees(model = bst, names = agaricus.train$data@Dimnames[[2]], 3)
})