R-callbacks tests + other tests brushup

This commit is contained in:
Vadim Khotilovich
2016-06-09 02:53:37 -05:00
parent 2e0ffcc303
commit f34f9fb9f7
6 changed files with 372 additions and 61 deletions

View File

@@ -5,10 +5,10 @@ set.seed(1994)
test_that("poisson regression works", {
data(mtcars)
bst <- xgboost(data = as.matrix(mtcars[,-11]),label = mtcars[,11],
objective = 'count:poisson', nrounds=5)
bst <- xgboost(data = as.matrix(mtcars[,-11]), label = mtcars[,11],
objective = 'count:poisson', nrounds=10, verbose=0)
expect_equal(class(bst), "xgb.Booster")
pred <- predict(bst,as.matrix(mtcars[, -11]))
pred <- predict(bst, as.matrix(mtcars[, -11]))
expect_equal(length(pred), 32)
expect_less_than(sqrt(mean( (pred - mtcars[,11]) ^ 2)), 2.5)
expect_lt(sqrt(mean( (pred - mtcars[,11])^2 )), 1.2)
})