TST: Added test for poisson regression
This commit is contained in:
parent
3a49e1bdb1
commit
c50cf6d7ff
13
R-package/tests/testthat/test_poisson_regression.R
Normal file
13
R-package/tests/testthat/test_poisson_regression.R
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
context('Test poisson regression model')
|
||||||
|
|
||||||
|
require(xgboost)
|
||||||
|
|
||||||
|
test_that("poisson regression works", {
|
||||||
|
data(mtcars)
|
||||||
|
bst = xgboost(data=as.matrix(mtcars[,-11]),label=mtcars[,11],
|
||||||
|
objective='count:poisson',nrounds=5)
|
||||||
|
expect_equal(class(bst), "xgb.Booster")
|
||||||
|
pred = predict(bst,as.matrix(mtcars[,-11]))
|
||||||
|
expect_equal(length(pred), 32)
|
||||||
|
sqrt(mean((pred-mtcars[,11])^2))
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user