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

[R-package] silence more logs in tests (#5208)

parent eababef8
...@@ -156,6 +156,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec ...@@ -156,6 +156,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec
num_leaves = 5L num_leaves = 5L
, objective = "binary" , objective = "binary"
, metric = "binary_error" , metric = "binary_error"
, verbose = VERBOSITY
) )
, nrounds = nrounds , nrounds = nrounds
) )
...@@ -173,6 +174,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec ...@@ -173,6 +174,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec
num_leaves = 5L num_leaves = 5L
, objective = "regression" , objective = "regression"
, metric = "l2" , metric = "l2"
, verbose = VERBOSITY
) )
, nrounds = nrounds , nrounds = nrounds
) )
...@@ -206,6 +208,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete ...@@ -206,6 +208,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete
objective = "regression" objective = "regression"
, metric = "l2" , metric = "l2"
, num_leaves = 5L , num_leaves = 5L
, verbose = VERBOSITY
) )
) )
...@@ -218,6 +221,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete ...@@ -218,6 +221,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete
, metric = "l2" , metric = "l2"
, num_leaves = 5L , num_leaves = 5L
, nrounds = nrounds , nrounds = nrounds
, verbose = VERBOSITY
) )
) )
...@@ -231,6 +235,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete ...@@ -231,6 +235,7 @@ test_that("lightgbm() accepts nrounds as either a top-level argument or paramete
, metric = "l2" , metric = "l2"
, num_leaves = 5L , num_leaves = 5L
, nrounds = nrounds , nrounds = nrounds
, verbose = VERBOSITY
) )
) )
...@@ -335,6 +340,7 @@ test_that("cv works", { ...@@ -335,6 +340,7 @@ test_that("cv works", {
, metric = "l2,l1" , metric = "l2,l1"
, min_data = 1L , min_data = 1L
, learning_rate = 1.0 , learning_rate = 1.0
, verbose = VERBOSITY
) )
bst <- lgb.cv( bst <- lgb.cv(
params params
...@@ -431,6 +437,7 @@ test_that("lightgbm.cv() gives the correct best_score and best_iter for a metric ...@@ -431,6 +437,7 @@ test_that("lightgbm.cv() gives the correct best_score and best_iter for a metric
, metric = "auc,binary_error" , metric = "auc,binary_error"
, learning_rate = 1.5 , learning_rate = 1.5
, num_leaves = 5L , num_leaves = 5L
, verbose = VERBOSITY
) )
) )
expect_true(methods::is(cv_bst, "lgb.CVBooster")) expect_true(methods::is(cv_bst, "lgb.CVBooster"))
...@@ -491,6 +498,7 @@ test_that("lgb.cv() respects showsd argument", { ...@@ -491,6 +498,7 @@ test_that("lgb.cv() respects showsd argument", {
objective = "regression" objective = "regression"
, metric = "l2" , metric = "l2"
, min_data = 1L , min_data = 1L
, verbose = VERBOSITY
) )
nrounds <- 5L nrounds <- 5L
set.seed(708L) set.seed(708L)
...@@ -549,6 +557,7 @@ test_that("lgb.cv() respects parameter aliases for objective", { ...@@ -549,6 +557,7 @@ test_that("lgb.cv() respects parameter aliases for objective", {
num_leaves = 5L num_leaves = 5L
, application = "binary" , application = "binary"
, num_iterations = nrounds , num_iterations = nrounds
, verbose = VERBOSITY
) )
, nfold = nfold , nfold = nfold
) )
...@@ -600,6 +609,7 @@ test_that("lgb.cv() respects parameter aliases for metric", { ...@@ -600,6 +609,7 @@ test_that("lgb.cv() respects parameter aliases for metric", {
, objective = "binary" , objective = "binary"
, num_iterations = nrounds , num_iterations = nrounds
, metric_types = c("auc", "binary_logloss") , metric_types = c("auc", "binary_logloss")
, verbose = VERBOSITY
) )
, nfold = nfold , nfold = nfold
) )
...@@ -616,6 +626,7 @@ test_that("lgb.cv() respects eval_train_metric argument", { ...@@ -616,6 +626,7 @@ test_that("lgb.cv() respects eval_train_metric argument", {
objective = "regression" objective = "regression"
, metric = "l2" , metric = "l2"
, min_data = 1L , min_data = 1L
, verbose = VERBOSITY
) )
nrounds <- 5L nrounds <- 5L
set.seed(708L) set.seed(708L)
...@@ -707,6 +718,7 @@ test_that("lgb.train() respects parameter aliases for objective", { ...@@ -707,6 +718,7 @@ test_that("lgb.train() respects parameter aliases for objective", {
num_leaves = 5L num_leaves = 5L
, application = "binary" , application = "binary"
, num_iterations = nrounds , num_iterations = nrounds
, verbose = VERBOSITY
) )
, valids = list( , valids = list(
"the_training_data" = dtrain "the_training_data" = dtrain
...@@ -755,6 +767,7 @@ test_that("lgb.train() respects parameter aliases for metric", { ...@@ -755,6 +767,7 @@ test_that("lgb.train() respects parameter aliases for metric", {
, objective = "binary" , objective = "binary"
, num_iterations = nrounds , num_iterations = nrounds
, metric_types = c("auc", "binary_logloss") , metric_types = c("auc", "binary_logloss")
, verbose = VERBOSITY
) )
, valids = list( , valids = list(
"train" = dtrain "train" = dtrain
...@@ -1722,6 +1735,7 @@ test_that("lgb.train() works with integer, double, and numeric data", { ...@@ -1722,6 +1735,7 @@ test_that("lgb.train() works with integer, double, and numeric data", {
, min_data_in_leaf = 1L , min_data_in_leaf = 1L
, learning_rate = 0.01 , learning_rate = 0.01
, seed = 708L , seed = 708L
, verbose = VERBOSITY
) )
, nrounds = nrounds , nrounds = nrounds
) )
...@@ -2061,6 +2075,7 @@ test_that("lgb.cv() works when you specify both 'metric' and 'eval' with strings ...@@ -2061,6 +2075,7 @@ test_that("lgb.cv() works when you specify both 'metric' and 'eval' with strings
params = list( params = list(
objective = "binary" objective = "binary"
, metric = "binary_error" , metric = "binary_error"
, verbose = VERBOSITY
) )
, data = DTRAIN_RANDOM_CLASSIFICATION , data = DTRAIN_RANDOM_CLASSIFICATION
, nrounds = nrounds , nrounds = nrounds
...@@ -2094,6 +2109,7 @@ test_that("lgb.cv() works when you give a function for eval", { ...@@ -2094,6 +2109,7 @@ test_that("lgb.cv() works when you give a function for eval", {
params = list( params = list(
objective = "binary" objective = "binary"
, metric = "None" , metric = "None"
, verbose = VERBOSITY
) )
, data = DTRAIN_RANDOM_CLASSIFICATION , data = DTRAIN_RANDOM_CLASSIFICATION
, nfold = nfolds , nfold = nfolds
...@@ -2119,6 +2135,7 @@ test_that("If first_metric_only is TRUE, lgb.cv() decides to stop early based on ...@@ -2119,6 +2135,7 @@ test_that("If first_metric_only is TRUE, lgb.cv() decides to stop early based on
, metric = "None" , metric = "None"
, early_stopping_rounds = early_stopping_rounds , early_stopping_rounds = early_stopping_rounds
, first_metric_only = TRUE , first_metric_only = TRUE
, verbose = VERBOSITY
) )
, data = DTRAIN_RANDOM_REGRESSION , data = DTRAIN_RANDOM_REGRESSION
, nfold = nfolds , nfold = nfolds
...@@ -2175,6 +2192,7 @@ test_that("early stopping works with lgb.cv()", { ...@@ -2175,6 +2192,7 @@ test_that("early stopping works with lgb.cv()", {
, metric = "None" , metric = "None"
, early_stopping_rounds = early_stopping_rounds , early_stopping_rounds = early_stopping_rounds
, first_metric_only = TRUE , first_metric_only = TRUE
, verbose = VERBOSITY
) )
, data = DTRAIN_RANDOM_REGRESSION , data = DTRAIN_RANDOM_REGRESSION
, nfold = nfolds , nfold = nfolds
...@@ -2620,7 +2638,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is ...@@ -2620,7 +2638,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is
set.seed(1L) set.seed(1L)
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
params <- list(objective = "regression", interaction_constraints = list(c(1L, 2L), 3L)) params <- list(
objective = "regression"
, interaction_constraints = list(c(1L, 2L), 3L)
, verbose = VERBOSITY
)
bst <- lightgbm( bst <- lightgbm(
data = dtrain data = dtrain
, params = params , params = params
...@@ -2629,7 +2651,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is ...@@ -2629,7 +2651,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is
pred1 <- bst$predict(test$data) pred1 <- bst$predict(test$data)
cnames <- colnames(train$data) cnames <- colnames(train$data)
params <- list(objective = "regression", interaction_constraints = list(c(cnames[[1L]], cnames[[2L]]), cnames[[3L]])) params <- list(
objective = "regression"
, interaction_constraints = list(c(cnames[[1L]], cnames[[2L]]), cnames[[3L]])
, verbose = VERBOSITY
)
bst <- lightgbm( bst <- lightgbm(
data = dtrain data = dtrain
, params = params , params = params
...@@ -2637,7 +2663,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is ...@@ -2637,7 +2663,11 @@ test_that(paste0("lgb.train() gives same result when interaction_constraints is
) )
pred2 <- bst$predict(test$data) pred2 <- bst$predict(test$data)
params <- list(objective = "regression", interaction_constraints = list(c(cnames[[1L]], cnames[[2L]]), 3L)) params <- list(
objective = "regression"
, interaction_constraints = list(c(cnames[[1L]], cnames[[2L]]), 3L)
, verbose = VERBOSITY
)
bst <- lightgbm( bst <- lightgbm(
data = dtrain data = dtrain
, params = params , params = params
...@@ -2654,7 +2684,11 @@ test_that(paste0("lgb.train() gives same results when using interaction_constrai ...@@ -2654,7 +2684,11 @@ test_that(paste0("lgb.train() gives same results when using interaction_constrai
set.seed(1L) set.seed(1L)
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
params <- list(objective = "regression", interaction_constraints = list(c(1L, 2L), 3L)) params <- list(
objective = "regression"
, interaction_constraints = list(c(1L, 2L), 3L)
, verbose = VERBOSITY
)
bst <- lightgbm( bst <- lightgbm(
data = dtrain data = dtrain
, params = params , params = params
...@@ -2663,8 +2697,11 @@ test_that(paste0("lgb.train() gives same results when using interaction_constrai ...@@ -2663,8 +2697,11 @@ test_that(paste0("lgb.train() gives same results when using interaction_constrai
pred1 <- bst$predict(test$data) pred1 <- bst$predict(test$data)
new_colnames <- paste0(colnames(train$data), "_x") new_colnames <- paste0(colnames(train$data), "_x")
params <- list(objective = "regression" params <- list(
, interaction_constraints = list(c(new_colnames[1L], new_colnames[2L]), new_colnames[3L])) objective = "regression"
, interaction_constraints = list(c(new_colnames[1L], new_colnames[2L]), new_colnames[3L])
, verbose = VERBOSITY
)
bst <- lightgbm( bst <- lightgbm(
data = dtrain data = dtrain
, params = params , params = params
...@@ -2807,6 +2844,7 @@ for (x3_to_categorical in c(TRUE, FALSE)) { ...@@ -2807,6 +2844,7 @@ for (x3_to_categorical in c(TRUE, FALSE)) {
, monotone_constraints = c(1L, -1L, 0L) , monotone_constraints = c(1L, -1L, 0L)
, monotone_constraints_method = monotone_constraints_method , monotone_constraints_method = monotone_constraints_method
, use_missing = FALSE , use_missing = FALSE
, verbose = VERBOSITY
) )
constrained_model <- lgb.train( constrained_model <- lgb.train(
params = params params = params
...@@ -2830,7 +2868,7 @@ test_that("lightgbm() accepts objective as function argument and under params", ...@@ -2830,7 +2868,7 @@ test_that("lightgbm() accepts objective as function argument and under params",
, label = train$label , label = train$label
, params = list(objective = "regression_l1") , params = list(objective = "regression_l1")
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
expect_equal(bst1$params$objective, "regression_l1") expect_equal(bst1$params$objective, "regression_l1")
model_txt_lines <- strsplit( model_txt_lines <- strsplit(
...@@ -2845,7 +2883,7 @@ test_that("lightgbm() accepts objective as function argument and under params", ...@@ -2845,7 +2883,7 @@ test_that("lightgbm() accepts objective as function argument and under params",
, label = train$label , label = train$label
, objective = "regression_l1" , objective = "regression_l1"
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
expect_equal(bst2$params$objective, "regression_l1") expect_equal(bst2$params$objective, "regression_l1")
model_txt_lines <- strsplit( model_txt_lines <- strsplit(
...@@ -2863,7 +2901,7 @@ test_that("lightgbm() prioritizes objective under params over objective as funct ...@@ -2863,7 +2901,7 @@ test_that("lightgbm() prioritizes objective under params over objective as funct
, objective = "regression" , objective = "regression"
, params = list(objective = "regression_l1") , params = list(objective = "regression_l1")
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
expect_equal(bst1$params$objective, "regression_l1") expect_equal(bst1$params$objective, "regression_l1")
model_txt_lines <- strsplit( model_txt_lines <- strsplit(
...@@ -2879,7 +2917,7 @@ test_that("lightgbm() prioritizes objective under params over objective as funct ...@@ -2879,7 +2917,7 @@ test_that("lightgbm() prioritizes objective under params over objective as funct
, objective = "regression" , objective = "regression"
, params = list(loss = "regression_l1") , params = list(loss = "regression_l1")
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
expect_equal(bst2$params$objective, "regression_l1") expect_equal(bst2$params$objective, "regression_l1")
model_txt_lines <- strsplit( model_txt_lines <- strsplit(
...@@ -2896,7 +2934,7 @@ test_that("lightgbm() accepts init_score as function argument", { ...@@ -2896,7 +2934,7 @@ test_that("lightgbm() accepts init_score as function argument", {
, label = train$label , label = train$label
, objective = "binary" , objective = "binary"
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
pred1 <- predict(bst1, train$data, rawscore = TRUE) pred1 <- predict(bst1, train$data, rawscore = TRUE)
...@@ -2906,7 +2944,7 @@ test_that("lightgbm() accepts init_score as function argument", { ...@@ -2906,7 +2944,7 @@ test_that("lightgbm() accepts init_score as function argument", {
, init_score = pred1 , init_score = pred1
, objective = "binary" , objective = "binary"
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
pred2 <- predict(bst2, train$data, rawscore = TRUE) pred2 <- predict(bst2, train$data, rawscore = TRUE)
...@@ -2918,7 +2956,7 @@ test_that("lightgbm() defaults to 'regression' objective if objective not otherw ...@@ -2918,7 +2956,7 @@ test_that("lightgbm() defaults to 'regression' objective if objective not otherw
data = train$data data = train$data
, label = train$label , label = train$label
, nrounds = 5L , nrounds = 5L
, verbose = -1L , verbose = VERBOSITY
) )
expect_equal(bst$params$objective, "regression") expect_equal(bst$params$objective, "regression")
model_txt_lines <- strsplit( model_txt_lines <- strsplit(
......
...@@ -83,6 +83,7 @@ test_that("learning-to-rank with lgb.cv() works as expected", { ...@@ -83,6 +83,7 @@ test_that("learning-to-rank with lgb.cv() works as expected", {
, label_gain = "0,1,3" , label_gain = "0,1,3"
, min_data = 1L , min_data = 1L
, learning_rate = 0.01 , learning_rate = 0.01
, verbose = VERBOSITY
) )
nfold <- 4L nfold <- 4L
nrounds <- 10L nrounds <- 10L
......
...@@ -480,6 +480,7 @@ test_that("Booster$eval() should work on a Dataset stored in a binary file", { ...@@ -480,6 +480,7 @@ test_that("Booster$eval() should work on a Dataset stored in a binary file", {
eval_from_file <- bst$eval( eval_from_file <- bst$eval(
data = lgb.Dataset( data = lgb.Dataset(
data = test_file data = test_file
, params = list(verbose = VERBOSITY)
)$construct() )$construct()
, name = "test" , name = "test"
) )
...@@ -551,6 +552,7 @@ test_that("Booster$update() passing a train_set works as expected", { ...@@ -551,6 +552,7 @@ test_that("Booster$update() passing a train_set works as expected", {
train_set = Dataset$new( train_set = Dataset$new(
data = agaricus.train$data data = agaricus.train$data
, label = agaricus.train$label , label = agaricus.train$label
, params = list(verbose = VERBOSITY)
) )
) )
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
......
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