This commit is contained in:
hetong007 2015-08-27 16:02:41 -07:00
parent 4554da0537
commit 5773d4d3c4

View File

@ -2,19 +2,18 @@ require(xgboost)
context("basic functions") context("basic functions")
test_that("data loading", { data(agaricus.train, package='xgboost')
data(agaricus.train, package='xgboost') data(agaricus.test, package='xgboost')
data(agaricus.test, package='xgboost') train = agaricus.train
}) test = agaricus.test
test_that("train and prediction",{ test_that("train and predict", {
train = agaricus.train
test = agaricus.test
bst = xgboost(data = train$data, label = train$label, max.depth = 2, bst = xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2, objective = "binary:logistic") eta = 1, nthread = 2, nround = 2, objective = "binary:logistic")
pred = predict(bst, test$data) pred = predict(bst, test$data)
}) })
test_that("early stopping", { test_that("early stopping", {
res = xgb.cv(data = train$data, label = train$label, max.depth = 2, nfold = 5, res = xgb.cv(data = train$data, label = train$label, max.depth = 2, nfold = 5,
eta = 0.3, nthread = 2, nround = 20, objective = "binary:logistic", eta = 0.3, nthread = 2, nround = 20, objective = "binary:logistic",