Minor addition to R unit tests

This commit is contained in:
terrytangyuan
2015-10-30 19:48:00 -05:00
parent 9cdcc8303b
commit e23f4ec3db
3 changed files with 12 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
context('Test poisson regression model')
require(xgboost)
set.seed(1994)
test_that("poisson regression works", {
data(mtcars)
@@ -9,5 +10,5 @@ test_that("poisson regression works", {
expect_equal(class(bst), "xgb.Booster")
pred <- predict(bst,as.matrix(mtcars[, -11]))
expect_equal(length(pred), 32)
sqrt(mean( (pred - mtcars[,11]) ^ 2))
})
expect_equal(sqrt(mean( (pred - mtcars[,11]) ^ 2)), 1.16, tolerance = 0.01)
})