Unverified Commit 3d620bfc authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] ensure boosting happens in tests on small datasets (#5121)

parent 78207462
......@@ -116,12 +116,20 @@ test_that("predictions for regression and binary classification are returned as
data(mtcars)
X <- as.matrix(mtcars[, -1L])
y <- as.numeric(mtcars[, 1L])
dtrain <- lgb.Dataset(X, label = y, params = list(max_bins = 5L))
dtrain <- lgb.Dataset(
X
, label = y
, params = list(
max_bins = 5L
, min_data_in_bin = 1L
)
)
model <- lgb.train(
data = dtrain
, obj = "regression"
, nrounds = 5L
, verbose = VERBOSITY
, params = list(min_data_in_leaf = 1L)
)
pred <- predict(model, X)
expect_true(is.vector(pred))
......
......@@ -1718,7 +1718,8 @@ test_that("lgb.train() works with integer, double, and numeric data", {
, label = y
, params = list(
objective = "regression"
, min_data = 1L
, min_data_in_bin = 1L
, min_data_in_leaf = 1L
, learning_rate = 0.01
, seed = 708L
)
......@@ -2984,7 +2985,11 @@ test_that("lightgbm() accepts 'weight' and 'weights'", {
, weights = w
, obj = "regression"
, nrounds = 5L
, verbose = -1L
, verbose = VERBOSITY
, params = list(
min_data_in_bin = 1L
, min_data_in_leaf = 1L
)
)
expect_equal(model$.__enclos_env__$private$train_set$get_field("weight"), w)
......
......@@ -1273,10 +1273,17 @@ test_that("Booster's print, show, and summary work correctly", {
data("mtcars")
model <- lgb.train(
params = list(objective = "regression")
params = list(
objective = "regression"
, min_data_in_leaf = 1L
)
, data = lgb.Dataset(
as.matrix(mtcars[, -1L])
, label = mtcars$mpg)
, label = mtcars$mpg
, params = list(
min_data_in_bin = 1L
)
)
, verbose = VERBOSITY
, nrounds = 5L
)
......@@ -1332,10 +1339,17 @@ test_that("Booster's print, show, and summary work correctly", {
test_that("LGBM_BoosterGetNumFeature_R returns correct outputs", {
data("mtcars")
model <- lgb.train(
params = list(objective = "regression")
params = list(
objective = "regression"
, min_data_in_leaf = 1L
)
, data = lgb.Dataset(
as.matrix(mtcars[, -1L])
, label = mtcars$mpg)
, label = mtcars$mpg
, params = list(
min_data_in_bin = 1L
)
)
, verbose = VERBOSITY
, nrounds = 5L
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment