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

[R-package] fix R CMD check NOTE about leftover files (#3181)

* [R-package] fix R CMD check NOTE about leftover files

* update number of allowed notes
parent bca2da97
...@@ -124,7 +124,7 @@ if ($env:COMPILER -ne "MSVC") { ...@@ -124,7 +124,7 @@ if ($env:COMPILER -ne "MSVC") {
.\miktex\download\miktexsetup.exe --remote-package-repository="$env:CTAN_PACKAGE_ARCHIVE" --portable="$env:R_LIB_PATH/miktex" --quiet install ; Check-Output $? .\miktex\download\miktexsetup.exe --remote-package-repository="$env:CTAN_PACKAGE_ARCHIVE" --portable="$env:R_LIB_PATH/miktex" --quiet install ; Check-Output $?
Write-Output "Done installing MiKTeX" Write-Output "Done installing MiKTeX"
Run-R-Code-Redirect-Stderr "processx::run(command = 'initexmf', args = c('--set-config-value', '[MPM]AutoInstall=1'), windows_verbatim_args = TRUE)" ; Check-Output $? Run-R-Code-Redirect-Stderr "result <- processx::run(command = 'initexmf', args = c('--set-config-value', '[MPM]AutoInstall=1'), echo = TRUE, windows_verbatim_args = TRUE)" ; Check-Output $?
conda install -q -y --no-deps pandoc conda install -q -y --no-deps pandoc
} }
...@@ -140,7 +140,7 @@ if ($env:COMPILER -ne "MSVC") { ...@@ -140,7 +140,7 @@ if ($env:COMPILER -ne "MSVC") {
$env:_R_CHECK_FORCE_SUGGESTS_ = 0 $env:_R_CHECK_FORCE_SUGGESTS_ = 0
Write-Output "Running R CMD check as CRAN" Write-Output "Running R CMD check as CRAN"
Run-R-Code-Redirect-Stderr "processx::run(command = 'R.exe', args = c('CMD', 'check', '--no-multiarch', '--as-cran', '$PKG_FILE_NAME'), windows_verbatim_args = FALSE)" ; $check_succeeded = $? Run-R-Code-Redirect-Stderr "result <- processx::run(command = 'R.exe', args = c('CMD', 'check', '--no-multiarch', '--as-cran', '$PKG_FILE_NAME'), echo = TRUE, windows_verbatim_args = FALSE)" ; $check_succeeded = $?
Write-Output "R CMD check build logs:" Write-Output "R CMD check build logs:"
$INSTALL_LOG_FILE_NAME = "$env:BUILD_SOURCESDIRECTORY\lightgbm.Rcheck\00install.out" $INSTALL_LOG_FILE_NAME = "$env:BUILD_SOURCESDIRECTORY\lightgbm.Rcheck\00install.out"
...@@ -157,7 +157,7 @@ if ($env:COMPILER -ne "MSVC") { ...@@ -157,7 +157,7 @@ if ($env:COMPILER -ne "MSVC") {
$note_str = Get-Content -Path "${LOG_FILE_NAME}" | Select-String -Pattern '.*Status.* NOTE' | Out-String ; Check-Output $? $note_str = Get-Content -Path "${LOG_FILE_NAME}" | Select-String -Pattern '.*Status.* NOTE' | Out-String ; Check-Output $?
$relevant_line = $note_str -match '(\d+) NOTE' $relevant_line = $note_str -match '(\d+) NOTE'
$NUM_CHECK_NOTES = $matches[1] $NUM_CHECK_NOTES = $matches[1]
$ALLOWED_CHECK_NOTES = 4 $ALLOWED_CHECK_NOTES = 3
if ([int]$NUM_CHECK_NOTES -gt $ALLOWED_CHECK_NOTES) { if ([int]$NUM_CHECK_NOTES -gt $ALLOWED_CHECK_NOTES) {
Write-Output "Found ${NUM_CHECK_NOTES} NOTEs from R CMD check. Only ${ALLOWED_CHECK_NOTES} are allowed" Write-Output "Found ${NUM_CHECK_NOTES} NOTEs from R CMD check. Only ${ALLOWED_CHECK_NOTES} are allowed"
Check-Output $False Check-Output $False
......
...@@ -789,8 +789,9 @@ predict.lgb.Booster <- function(object, ...@@ -789,8 +789,9 @@ predict.lgb.Booster <- function(object,
#' , learning_rate = 1.0 #' , learning_rate = 1.0
#' , early_stopping_rounds = 3L #' , early_stopping_rounds = 3L
#' ) #' )
#' lgb.save(model, "model.txt") #' model_file <- tempfile(fileext = ".txt")
#' load_booster <- lgb.load(filename = "model.txt") #' lgb.save(model, model_file)
#' load_booster <- lgb.load(filename = model_file)
#' model_string <- model$save_model_to_string(NULL) # saves best iteration #' model_string <- model$save_model_to_string(NULL) # saves best iteration
#' load_booster_from_str <- lgb.load(model_str = model_string) #' load_booster_from_str <- lgb.load(model_str = model_string)
#' } #' }
...@@ -849,7 +850,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) { ...@@ -849,7 +850,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
#' , learning_rate = 1.0 #' , learning_rate = 1.0
#' , early_stopping_rounds = 5L #' , early_stopping_rounds = 5L
#' ) #' )
#' lgb.save(model, "lgb-model.txt") #' lgb.save(model, tempfile(fileext = ".txt"))
#' } #' }
#' @export #' @export
lgb.save <- function(booster, filename, num_iteration = NULL) { lgb.save <- function(booster, filename, num_iteration = NULL) {
......
...@@ -728,8 +728,9 @@ Dataset <- R6::R6Class( ...@@ -728,8 +728,9 @@ Dataset <- R6::R6Class(
#' data(agaricus.train, package = "lightgbm") #' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train #' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label) #' dtrain <- lgb.Dataset(train$data, label = train$label)
#' lgb.Dataset.save(dtrain, "lgb.Dataset.data") #' data_file <- tempfile(fileext = ".data")
#' dtrain <- lgb.Dataset("lgb.Dataset.data") #' lgb.Dataset.save(dtrain, data_file)
#' dtrain <- lgb.Dataset(data_file)
#' lgb.Dataset.construct(dtrain) #' lgb.Dataset.construct(dtrain)
#' #'
#' @export #' @export
...@@ -1073,8 +1074,9 @@ setinfo.lgb.Dataset <- function(dataset, name, info, ...) { ...@@ -1073,8 +1074,9 @@ setinfo.lgb.Dataset <- function(dataset, name, info, ...) {
#' data(agaricus.train, package = "lightgbm") #' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train #' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label) #' dtrain <- lgb.Dataset(train$data, label = train$label)
#' lgb.Dataset.save(dtrain, "lgb-Dataset.data") #' data_file <- tempfile(fileext = ".data")
#' dtrain <- lgb.Dataset("lgb-Dataset.data") #' lgb.Dataset.save(dtrain, data_file)
#' dtrain <- lgb.Dataset(data_file)
#' lgb.Dataset.set.categorical(dtrain, 1L:2L) #' lgb.Dataset.set.categorical(dtrain, 1L:2L)
#' #'
#' @rdname lgb.Dataset.set.categorical #' @rdname lgb.Dataset.set.categorical
...@@ -1134,7 +1136,7 @@ lgb.Dataset.set.reference <- function(dataset, reference) { ...@@ -1134,7 +1136,7 @@ lgb.Dataset.set.reference <- function(dataset, reference) {
#' data(agaricus.train, package = "lightgbm") #' data(agaricus.train, package = "lightgbm")
#' train <- agaricus.train #' train <- agaricus.train
#' dtrain <- lgb.Dataset(train$data, label = train$label) #' dtrain <- lgb.Dataset(train$data, label = train$label)
#' lgb.Dataset.save(dtrain, "data.bin") #' lgb.Dataset.save(dtrain, tempfile(fileext = ".bin"))
#' @export #' @export
lgb.Dataset.save <- function(dataset, fname) { lgb.Dataset.save <- function(dataset, fname) {
......
...@@ -26,8 +26,9 @@ ...@@ -26,8 +26,9 @@
#' , learning_rate = 1.0 #' , learning_rate = 1.0
#' , early_stopping_rounds = 5L #' , early_stopping_rounds = 5L
#' ) #' )
#' saveRDS.lgb.Booster(model, "model.rds") #' model_file <- tempfile(fileext = ".rds")
#' new_model <- readRDS.lgb.Booster("model.rds") #' saveRDS.lgb.Booster(model, model_file)
#' new_model <- readRDS.lgb.Booster(model_file)
#' } #' }
#' @export #' @export
readRDS.lgb.Booster <- function(file = "", refhook = NULL) { readRDS.lgb.Booster <- function(file = "", refhook = NULL) {
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
#' , learning_rate = 1.0 #' , learning_rate = 1.0
#' , early_stopping_rounds = 5L #' , early_stopping_rounds = 5L
#' ) #' )
#' saveRDS.lgb.Booster(model, "lgb-model.rds") #' model_file <- tempfile(fileext = ".rds")
#' saveRDS.lgb.Booster(model, model_file)
#' } #' }
#' @export #' @export
saveRDS.lgb.Booster <- function(object, saveRDS.lgb.Booster <- function(object,
......
...@@ -43,8 +43,9 @@ Construct \code{lgb.Dataset} object from dense matrix, sparse matrix ...@@ -43,8 +43,9 @@ Construct \code{lgb.Dataset} object from dense matrix, sparse matrix
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
lgb.Dataset.save(dtrain, "lgb.Dataset.data") data_file <- tempfile(fileext = ".data")
dtrain <- lgb.Dataset("lgb.Dataset.data") lgb.Dataset.save(dtrain, data_file)
dtrain <- lgb.Dataset(data_file)
lgb.Dataset.construct(dtrain) lgb.Dataset.construct(dtrain)
} }
...@@ -22,5 +22,5 @@ Please note that \code{init_score} is not saved in binary file. ...@@ -22,5 +22,5 @@ Please note that \code{init_score} is not saved in binary file.
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
lgb.Dataset.save(dtrain, "data.bin") lgb.Dataset.save(dtrain, tempfile(fileext = ".bin"))
} }
...@@ -24,8 +24,9 @@ Set the categorical features of an \code{lgb.Dataset} object. Use this function ...@@ -24,8 +24,9 @@ Set the categorical features of an \code{lgb.Dataset} object. Use this function
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
lgb.Dataset.save(dtrain, "lgb-Dataset.data") data_file <- tempfile(fileext = ".data")
dtrain <- lgb.Dataset("lgb-Dataset.data") lgb.Dataset.save(dtrain, data_file)
dtrain <- lgb.Dataset(data_file)
lgb.Dataset.set.categorical(dtrain, 1L:2L) lgb.Dataset.set.categorical(dtrain, 1L:2L)
} }
...@@ -37,8 +37,9 @@ model <- lgb.train( ...@@ -37,8 +37,9 @@ model <- lgb.train(
, learning_rate = 1.0 , learning_rate = 1.0
, early_stopping_rounds = 3L , early_stopping_rounds = 3L
) )
lgb.save(model, "model.txt") model_file <- tempfile(fileext = ".txt")
load_booster <- lgb.load(filename = "model.txt") lgb.save(model, model_file)
load_booster <- lgb.load(filename = model_file)
model_string <- model$save_model_to_string(NULL) # saves best iteration model_string <- model$save_model_to_string(NULL) # saves best iteration
load_booster_from_str <- lgb.load(model_str = model_string) load_booster_from_str <- lgb.load(model_str = model_string)
} }
......
...@@ -39,6 +39,6 @@ model <- lgb.train( ...@@ -39,6 +39,6 @@ model <- lgb.train(
, learning_rate = 1.0 , learning_rate = 1.0
, early_stopping_rounds = 5L , early_stopping_rounds = 5L
) )
lgb.save(model, "lgb-model.txt") lgb.save(model, tempfile(fileext = ".txt"))
} }
} }
...@@ -37,7 +37,8 @@ model <- lgb.train( ...@@ -37,7 +37,8 @@ model <- lgb.train(
, learning_rate = 1.0 , learning_rate = 1.0
, early_stopping_rounds = 5L , early_stopping_rounds = 5L
) )
saveRDS.lgb.Booster(model, "model.rds") model_file <- tempfile(fileext = ".rds")
new_model <- readRDS.lgb.Booster("model.rds") saveRDS.lgb.Booster(model, model_file)
new_model <- readRDS.lgb.Booster(model_file)
} }
} }
...@@ -61,6 +61,7 @@ model <- lgb.train( ...@@ -61,6 +61,7 @@ model <- lgb.train(
, learning_rate = 1.0 , learning_rate = 1.0
, early_stopping_rounds = 5L , early_stopping_rounds = 5L
) )
saveRDS.lgb.Booster(model, "lgb-model.rds") model_file <- tempfile(fileext = ".rds")
saveRDS.lgb.Booster(model, model_file)
} }
} }
...@@ -16,6 +16,7 @@ test_that("train and predict binary classification", { ...@@ -16,6 +16,7 @@ test_that("train and predict binary classification", {
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, metric = "binary_error" , metric = "binary_error"
, save_name = tempfile(fileext = ".model")
) )
expect_false(is.null(bst$record_evals)) expect_false(is.null(bst$record_evals))
record_results <- lgb.get.eval.result(bst, "train", "binary_error") record_results <- lgb.get.eval.result(bst, "train", "binary_error")
...@@ -47,6 +48,7 @@ test_that("train and predict softmax", { ...@@ -47,6 +48,7 @@ test_that("train and predict softmax", {
, objective = "multiclass" , objective = "multiclass"
, metric = "multi_error" , metric = "multi_error"
, num_class = 3L , num_class = 3L
, save_name = tempfile(fileext = ".model")
) )
expect_false(is.null(bst$record_evals)) expect_false(is.null(bst$record_evals))
...@@ -68,6 +70,7 @@ test_that("use of multiple eval metrics works", { ...@@ -68,6 +70,7 @@ test_that("use of multiple eval metrics works", {
, nrounds = 10L , nrounds = 10L
, objective = "binary" , objective = "binary"
, metric = metrics , metric = metrics
, save_name = tempfile(fileext = ".model")
) )
expect_false(is.null(bst$record_evals)) expect_false(is.null(bst$record_evals))
expect_named( expect_named(
...@@ -88,6 +91,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec ...@@ -88,6 +91,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, metric = "binary_error" , metric = "binary_error"
, save_name = tempfile(fileext = ".model")
) )
expect_true(abs(bst$lower_bound() - -1.590853) < TOLERANCE) expect_true(abs(bst$lower_bound() - -1.590853) < TOLERANCE)
expect_true(abs(bst$upper_bound() - 1.871015) < TOLERANCE) expect_true(abs(bst$upper_bound() - 1.871015) < TOLERANCE)
...@@ -103,6 +107,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec ...@@ -103,6 +107,7 @@ test_that("lgb.Booster.upper_bound() and lgb.Booster.lower_bound() work as expec
, nrounds = nrounds , nrounds = nrounds
, objective = "regression" , objective = "regression"
, metric = "l2" , metric = "l2"
, save_name = tempfile(fileext = ".model")
) )
expect_true(abs(bst$lower_bound() - 0.1513859) < TOLERANCE) expect_true(abs(bst$lower_bound() - 0.1513859) < TOLERANCE)
expect_true(abs(bst$upper_bound() - 0.9080349) < TOLERANCE) expect_true(abs(bst$upper_bound() - 0.9080349) < TOLERANCE)
...@@ -117,6 +122,7 @@ test_that("lightgbm() rejects negative or 0 value passed to nrounds", { ...@@ -117,6 +122,7 @@ test_that("lightgbm() rejects negative or 0 value passed to nrounds", {
data = dtrain data = dtrain
, params = params , params = params
, nrounds = nround_value , nrounds = nround_value
, save_name = tempfile(fileext = ".model")
) )
}, "nrounds should be greater than zero") }, "nrounds should be greater than zero")
} }
...@@ -147,6 +153,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide ...@@ -147,6 +153,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
"valid1" = dvalid1 "valid1" = dvalid1
, "valid2" = dvalid2 , "valid2" = dvalid2
) )
, save_name = tempfile(fileext = ".model")
) )
expect_named( expect_named(
...@@ -188,13 +195,14 @@ test_that("training continuation works", { ...@@ -188,13 +195,14 @@ test_that("training continuation works", {
# first 5 iterations: # first 5 iterations:
bst1 <- lgb.train(param, dtrain, nrounds = 5L, watchlist) bst1 <- lgb.train(param, dtrain, nrounds = 5L, watchlist)
# test continuing from a model in file # test continuing from a model in file
lgb.save(bst1, "lightgbm.model") model_file <- tempfile(fileext = ".model")
lgb.save(bst1, model_file)
# continue for 5 more: # continue for 5 more:
bst2 <- lgb.train(param, dtrain, nrounds = 5L, watchlist, init_model = bst1) bst2 <- lgb.train(param, dtrain, nrounds = 5L, watchlist, init_model = bst1)
err_bst2 <- lgb.get.eval.result(bst2, "train", "binary_logloss", 10L) err_bst2 <- lgb.get.eval.result(bst2, "train", "binary_logloss", 10L)
expect_lt(abs(err_bst - err_bst2), 0.01) expect_lt(abs(err_bst - err_bst2), 0.01)
bst2 <- lgb.train(param, dtrain, nrounds = 5L, watchlist, init_model = "lightgbm.model") bst2 <- lgb.train(param, dtrain, nrounds = 5L, watchlist, init_model = model_file)
err_bst2 <- lgb.get.eval.result(bst2, "train", "binary_logloss", 10L) err_bst2 <- lgb.get.eval.result(bst2, "train", "binary_logloss", 10L)
expect_lt(abs(err_bst - err_bst2), 0.01) expect_lt(abs(err_bst - err_bst2), 0.01)
}) })
...@@ -1007,6 +1015,7 @@ test_that("using lightgbm() without early stopping, best_iter and best_score com ...@@ -1007,6 +1015,7 @@ test_that("using lightgbm() without early stopping, best_iter and best_score com
, learning_rate = 1.5 , learning_rate = 1.5
) )
, verbose = -7L , verbose = -7L
, save_name = tempfile(fileext = ".model")
) )
# when verbose <= 0 is passed to lightgbm(), 'valids' is passed through to lgb.train() # when verbose <= 0 is passed to lightgbm(), 'valids' is passed through to lgb.train()
# untouched. If you set verbose to > 0, the training data will still be first but called "train" # untouched. If you set verbose to > 0, the training data will still be first but called "train"
......
...@@ -104,6 +104,7 @@ test_that("lgb.load() gives the expected error messages given different incorrec ...@@ -104,6 +104,7 @@ test_that("lgb.load() gives the expected error messages given different incorrec
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = 2L , nrounds = 2L
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
# you have to give model_str or filename # you have to give model_str or filename
...@@ -115,9 +116,9 @@ test_that("lgb.load() gives the expected error messages given different incorrec ...@@ -115,9 +116,9 @@ test_that("lgb.load() gives the expected error messages given different incorrec
}, regexp = "either filename or model_str must be given") }, regexp = "either filename or model_str must be given")
# if given, filename should be a string that points to an existing file # if given, filename should be a string that points to an existing file
out_file <- "lightgbm.model" model_file <- tempfile(fileext = ".model")
expect_error({ expect_error({
lgb.load(filename = list(out_file)) lgb.load(filename = list(model_file))
}, regexp = "filename should be character") }, regexp = "filename should be character")
file_to_check <- paste0("a.model") file_to_check <- paste0("a.model")
while (file.exists(file_to_check)) { while (file.exists(file_to_check)) {
...@@ -147,11 +148,13 @@ test_that("Loading a Booster from a file works", { ...@@ -147,11 +148,13 @@ test_that("Loading a Booster from a file works", {
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = 2L , nrounds = 2L
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
pred <- predict(bst, test$data) pred <- predict(bst, test$data)
lgb.save(bst, "lightgbm.model") model_file <- tempfile(fileext = ".model")
lgb.save(bst, model_file)
# finalize the booster and destroy it so you know we aren't cheating # finalize the booster and destroy it so you know we aren't cheating
bst$finalize() bst$finalize()
...@@ -159,7 +162,7 @@ test_that("Loading a Booster from a file works", { ...@@ -159,7 +162,7 @@ test_that("Loading a Booster from a file works", {
rm(bst) rm(bst)
bst2 <- lgb.load( bst2 <- lgb.load(
filename = "lightgbm.model" filename = model_file
) )
pred2 <- predict(bst2, test$data) pred2 <- predict(bst2, test$data)
expect_identical(pred, pred2) expect_identical(pred, pred2)
...@@ -178,6 +181,7 @@ test_that("Loading a Booster from a string works", { ...@@ -178,6 +181,7 @@ test_that("Loading a Booster from a string works", {
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = 2L , nrounds = 2L
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
...@@ -209,11 +213,13 @@ test_that("If a string and a file are both passed to lgb.load() the file is used ...@@ -209,11 +213,13 @@ test_that("If a string and a file are both passed to lgb.load() the file is used
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = 2L , nrounds = 2L
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
pred <- predict(bst, test$data) pred <- predict(bst, test$data)
lgb.save(bst, "lightgbm.model") model_file <- tempfile(fileext = ".model")
lgb.save(bst, model_file)
# finalize the booster and destroy it so you know we aren't cheating # finalize the booster and destroy it so you know we aren't cheating
bst$finalize() bst$finalize()
...@@ -221,7 +227,7 @@ test_that("If a string and a file are both passed to lgb.load() the file is used ...@@ -221,7 +227,7 @@ test_that("If a string and a file are both passed to lgb.load() the file is used
rm(bst) rm(bst)
bst2 <- lgb.load( bst2 <- lgb.load(
filename = "lightgbm.model" filename = model_file
, model_str = 4.0 , model_str = 4.0
) )
pred2 <- predict(bst2, test$data) pred2 <- predict(bst2, test$data)
...@@ -261,6 +267,7 @@ test_that("Creating a Booster from a Dataset with an existing predictor should w ...@@ -261,6 +267,7 @@ test_that("Creating a Booster from a Dataset with an existing predictor should w
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
data(agaricus.test, package = "lightgbm") data(agaricus.test, package = "lightgbm")
dtest <- Dataset$new( dtest <- Dataset$new(
...@@ -294,6 +301,7 @@ test_that("Booster$rollback_one_iter() should work as expected", { ...@@ -294,6 +301,7 @@ test_that("Booster$rollback_one_iter() should work as expected", {
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_equal(bst$current_iter(), nrounds) expect_equal(bst$current_iter(), nrounds)
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
...@@ -325,6 +333,7 @@ test_that("Booster$update() passing a train_set works as expected", { ...@@ -325,6 +333,7 @@ test_that("Booster$update() passing a train_set works as expected", {
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_true(lgb.is.Booster(bst)) expect_true(lgb.is.Booster(bst))
expect_equal(bst$current_iter(), nrounds) expect_equal(bst$current_iter(), nrounds)
...@@ -345,6 +354,7 @@ test_that("Booster$update() passing a train_set works as expected", { ...@@ -345,6 +354,7 @@ test_that("Booster$update() passing a train_set works as expected", {
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = nrounds + 1L , nrounds = nrounds + 1L
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_true(lgb.is.Booster(bst2)) expect_true(lgb.is.Booster(bst2))
expect_equal(bst2$current_iter(), nrounds + 1L) expect_equal(bst2$current_iter(), nrounds + 1L)
...@@ -367,6 +377,7 @@ test_that("Booster$update() throws an informative error if you provide a non-Dat ...@@ -367,6 +377,7 @@ test_that("Booster$update() throws an informative error if you provide a non-Dat
, learning_rate = 1.0 , learning_rate = 1.0
, nrounds = nrounds , nrounds = nrounds
, objective = "binary" , objective = "binary"
, save_name = tempfile(fileext = ".model")
) )
expect_error({ expect_error({
bst$update( bst$update(
......
...@@ -24,6 +24,7 @@ test_that("Feature penalties work properly", { ...@@ -24,6 +24,7 @@ test_that("Feature penalties work properly", {
, feature_penalty = paste0(feature_penalties, collapse = ",") , feature_penalty = paste0(feature_penalties, collapse = ",")
, metric = "binary_error" , metric = "binary_error"
, verbose = -1L , verbose = -1L
, save_name = tempfile(fileext = ".model")
) )
}) })
...@@ -75,6 +76,7 @@ test_that("training should warn if you use 'dart' boosting, specified with 'boos ...@@ -75,6 +76,7 @@ test_that("training should warn if you use 'dart' boosting, specified with 'boos
object = "dart" object = "dart"
, nm = boosting_param , nm = boosting_param
) )
, save_name = tempfile(fileext = ".model")
) )
}, regexp = "Early stopping is not available in 'dart' mode") }, regexp = "Early stopping is not available in 'dart' mode")
} }
......
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