From 0652b6c45629abad6d22fc04f51fa1eb7922d218 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 24 Sep 2019 22:48:43 -0500 Subject: [PATCH 01/10] Disabled early stopping when using 'dart' boosting strategy --- R-package/R/lgb.cv.R | 44 ++++++++++++++++++++--------------------- R-package/R/lgb.train.R | 44 ++++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index 594b323df16d..82adf75c21aa 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -225,30 +225,30 @@ lgb.cv <- function(params = list(), callbacks <- add.cb(callbacks, cb.record.evaluation()) } - # Check for early stopping passed as parameter when adding early stopping callback + # If early stopping was passed as a parameter in params(), prefer that to keyword argument + # early_stopping_rounds by overwriting the value in 'early_stopping_rounds' early_stop <- c("early_stopping_round", "early_stopping_rounds", "early_stopping", "n_iter_no_change") - if (any(names(params) %in% early_stop)) { - if (params[[which(names(params) %in% early_stop)[1]]] > 0) { - callbacks <- add.cb( - callbacks - , cb.early.stop( - params[[which(names(params) %in% early_stop)[1]]] - , verbose = verbose - ) + early_stop_param_indx <- names(params) %in% early_stop + if (any(early_stop_param_indx)) { + first_early_stop_param <- which(early_stop_param_indx)[[1]] + first_early_stop_param_name <- names(params)[[first_early_stop_param]] + early_stopping_rounds <- params[[first_early_stop_param_name]] + } + + using_early_stopping <- !is.null(early_stopping_rounds) + if (using_early_stopping && identical(params$boosting, "dart")){ + warning("Early stopping is not available in 'dart' mode") + use_early_stopping <- FALSE + } + + if (using_early_stopping){ + callbacks <- add.cb( + callbacks + , cb.early.stop( + stopping_rounds = early_stopping_rounds + , verbose = verbose ) - } - } else { - if (!is.null(early_stopping_rounds)) { - if (early_stopping_rounds > 0) { - callbacks <- add.cb( - callbacks - , cb.early.stop( - early_stopping_rounds - , verbose = verbose - ) - ) - } - } + ) } # Categorize callbacks diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index 79c6b4e4898a..e9e298d8d123 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -207,30 +207,30 @@ lgb.train <- function(params = list(), callbacks <- add.cb(callbacks, cb.record.evaluation()) } - # Check for early stopping passed as parameter when adding early stopping callback + # If early stopping was passed as a parameter in params(), prefer that to keyword argument + # early_stopping_rounds by overwriting the value in 'early_stopping_rounds' early_stop <- c("early_stopping_round", "early_stopping_rounds", "early_stopping", "n_iter_no_change") - if (any(names(params) %in% early_stop)) { - if (params[[which(names(params) %in% early_stop)[1]]] > 0) { - callbacks <- add.cb( - callbacks - , cb.early.stop( - params[[which(names(params) %in% early_stop)[1]]] - , verbose = verbose - ) + early_stop_param_indx <- names(params) %in% early_stop + if (any(early_stop_param_indx)) { + first_early_stop_param <- which(early_stop_param_indx)[[1]] + first_early_stop_param_name <- names(params)[[first_early_stop_param]] + early_stopping_rounds <- params[[first_early_stop_param_name]] + } + + using_early_stopping <- !is.null(early_stopping_rounds) + if (using_early_stopping && identical(params$boosting, "dart")){ + warning("Early stopping is not available in 'dart' mode") + use_early_stopping <- FALSE + } + + if (using_early_stopping){ + callbacks <- add.cb( + callbacks + , cb.early.stop( + stopping_rounds = early_stopping_rounds + , verbose = verbose ) - } - } else { - if (!is.null(early_stopping_rounds)) { - if (early_stopping_rounds > 0) { - callbacks <- add.cb( - callbacks - , cb.early.stop( - early_stopping_rounds - , verbose = verbose - ) - ) - } - } + ) } # "Categorize" callbacks From 6cd303aa3292964a75b134626626a3d4361a6292 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 24 Sep 2019 22:59:52 -0500 Subject: [PATCH 02/10] added new early_stopping alias --- R-package/R/lgb.train.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index e9e298d8d123..1d292a182502 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -218,8 +218,8 @@ lgb.train <- function(params = list(), } using_early_stopping <- !is.null(early_stopping_rounds) - if (using_early_stopping && identical(params$boosting, "dart")){ - warning("Early stopping is not available in 'dart' mode") + if (identical(params$boosting, "dart")){ + warning("Early stopping is not available in 'dart' mode.") use_early_stopping <- FALSE } From b24ecfce36487fed3a6061500d277c025a894815 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 29 Sep 2019 11:36:59 -0500 Subject: [PATCH 03/10] added protection against use of 'cb.early.stop' --- R-package/R/lgb.cv.R | 22 +++++++++++++++++----- R-package/R/lgb.train.R | 18 +++++++++++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index 82adf75c21aa..a7766798b1e8 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -235,13 +235,25 @@ lgb.cv <- function(params = list(), early_stopping_rounds <- params[[first_early_stop_param_name]] } - using_early_stopping <- !is.null(early_stopping_rounds) - if (using_early_stopping && identical(params$boosting, "dart")){ - warning("Early stopping is not available in 'dart' mode") - use_early_stopping <- FALSE + # Did user pass parameters that indicate they want to use early stopping? + using_early_stopping_via_args <- !is.null(early_stopping_rounds) + + # Cannot use early stopping with 'dart' boosting + if (identical(params$boosting, "dart")){ + warning("Early stopping is not available in 'dart' mode.") + using_early_stopping_via_args <- FALSE + + # Remove the cb.early.stop() function if it was passed in to callbacks + callbacks <- Filter( + f = function(cb_func){ + !identical(attr(cb_func, "name"), "cb.early.stop") + } + , x = callbacks + ) } - if (using_early_stopping){ + # If user supplied early_stopping_rounds, add the early stopping callback + if (using_early_stopping_via_args){ callbacks <- add.cb( callbacks , cb.early.stop( diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index 1d292a182502..ce9358137b74 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -217,13 +217,25 @@ lgb.train <- function(params = list(), early_stopping_rounds <- params[[first_early_stop_param_name]] } - using_early_stopping <- !is.null(early_stopping_rounds) + # Did user pass parameters that indicate they want to use early stopping? + using_early_stopping_via_args <- !is.null(early_stopping_rounds) + + # Cannot use early stopping with 'dart' boosting if (identical(params$boosting, "dart")){ warning("Early stopping is not available in 'dart' mode.") - use_early_stopping <- FALSE + using_early_stopping_via_args <- FALSE + + # Remove the cb.early.stop() function if it was passed in to callbacks + callbacks <- Filter( + f = function(cb_func){ + !identical(attr(cb_func, "name"), "cb.early.stop") + } + , x = callbacks + ) } - if (using_early_stopping){ + # If user supplied early_stopping_rounds, add the early stopping callback + if (using_early_stopping_via_args){ callbacks <- add.cb( callbacks , cb.early.stop( From 6221426aab70a153f9e866464f21069e8a200485 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 29 Sep 2019 23:02:49 -0500 Subject: [PATCH 04/10] added support for boosting aliases in R package and test on skipping early boosting --- R-package/R/aliases.R | 15 ++++++++++++ R-package/R/callback.R | 7 +++++- R-package/R/lgb.cv.R | 12 +++++++++- R-package/R/lgb.train.R | 12 +++++++++- R-package/tests/testthat/test_parameters.R | 27 ++++++++++++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 R-package/R/aliases.R diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R new file mode 100644 index 000000000000..80d411f074b1 --- /dev/null +++ b/R-package/R/aliases.R @@ -0,0 +1,15 @@ +# Central location for paramter aliases. +# See https://lightgbm.readthedocs.io/en/latest/Parameters.html#core-parameters + +# [description] List of respected parameter aliases. Wrapped in a function to take advantage of +# lazy evaluation (so it doesn't matter what order R sources files during installation). +# [return] A named list, where each key is a main LightGBM parameter and each value is a character +# vector of corresponding aliases. +.PARAMETER_ALIASES <- function(){ + return(list( + "boosting" = c( + "boosting_type" + , "boost" + ) + )) +} diff --git a/R-package/R/callback.R b/R-package/R/callback.R index 92bd9c035a97..d6a010b19296 100644 --- a/R-package/R/callback.R +++ b/R-package/R/callback.R @@ -37,7 +37,12 @@ cb.reset.parameters <- function(new_params) { # Some parameters are not allowed to be changed, # since changing them would simply wreck some chaos - not_allowed <- c("num_class", "metric", "boosting_type") + not_allowed <- c( + "num_class" + , "metric" + , "boosting" + , .PARAMETER_ALIASES()[["boosting"]] + ) if (any(pnames %in% not_allowed)) { stop( "Parameters " diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index a7766798b1e8..980b712b9148 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -238,8 +238,18 @@ lgb.cv <- function(params = list(), # Did user pass parameters that indicate they want to use early stopping? using_early_stopping_via_args <- !is.null(early_stopping_rounds) + boosting_param_names <- c("boosting", .PARAMETER_ALIASES()[["boosting"]]) + using_dart <- any( + sapply( + X = boosting_param_names + , FUN = function(param){ + identical(params[[param]], 'dart') + } + ) + ) + # Cannot use early stopping with 'dart' boosting - if (identical(params$boosting, "dart")){ + if (using_dart){ warning("Early stopping is not available in 'dart' mode.") using_early_stopping_via_args <- FALSE diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index ce9358137b74..1900637fcdfc 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -220,8 +220,18 @@ lgb.train <- function(params = list(), # Did user pass parameters that indicate they want to use early stopping? using_early_stopping_via_args <- !is.null(early_stopping_rounds) + boosting_param_names <- c("boosting", .PARAMETER_ALIASES()[["boosting"]]) + using_dart <- any( + sapply( + X = boosting_param_names + , FUN = function(param){ + identical(params[[param]], 'dart') + } + ) + ) + # Cannot use early stopping with 'dart' boosting - if (identical(params$boosting, "dart")){ + if (using_dart){ warning("Early stopping is not available in 'dart' mode.") using_early_stopping_via_args <- FALSE diff --git a/R-package/tests/testthat/test_parameters.R b/R-package/tests/testthat/test_parameters.R index 60a762de2e59..9d6c75c861e5 100644 --- a/R-package/tests/testthat/test_parameters.R +++ b/R-package/tests/testthat/test_parameters.R @@ -43,3 +43,30 @@ test_that("Feature penalties work properly", { # Ensure that feature is not used when feature_penalty = 0 expect_length(var_gain[[length(var_gain)]], 0) }) + +expect_true(".PARAMETER_ALIASES() returns a named list", { + param_aliases <- .PARAMETER_ALIASES() + expect_true(is.list(param_aliases)) + expect_true(is.character(names(param_aliases))) +}) + +expect_true("training should warn if you use 'dart' boosting, specified with 'boosting' or aliases", { + for (boosting_param in c("boosting", .PARAMETER_ALIASES()[["boosting"]])){ + expect_warning({ + result <- lightgbm( + data = train$data + , label = train$label + , num_leaves = 5 + , learning_rate = 0.05 + , nrounds = 5 + , objective = "binary" + , metric = "binary_error" + , verbose = -1 + , params = stats::setNames( + object = "dart" + , nm = boosting_param + ) + ) + }, regexp = "Early stopping is not available in 'dart' mode") + } +}) From de026261e98cc0c6c2b070e1a1427ef54310782c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 23 Oct 2019 23:46:15 -0500 Subject: [PATCH 05/10] added more parameter alias coverage on R package --- R-package/R/aliases.R | 12 +++++++++++- R-package/R/callback.R | 5 ++--- R-package/tests/testthat/test_parameters.R | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R index 80d411f074b1..8ae11e87c504 100644 --- a/R-package/R/aliases.R +++ b/R-package/R/aliases.R @@ -8,8 +8,18 @@ .PARAMETER_ALIASES <- function(){ return(list( "boosting" = c( - "boosting_type" + "boosting" , "boost" + , "boosting_type" + ) + , "metric" = c( + "metric" + , "metrics" + , "metric_types" + ) + , "num_class" = c( + "num_class" + , "num_classes" ) )) } diff --git a/R-package/R/callback.R b/R-package/R/callback.R index d6a010b19296..1b5f4f4562a8 100644 --- a/R-package/R/callback.R +++ b/R-package/R/callback.R @@ -38,9 +38,8 @@ cb.reset.parameters <- function(new_params) { # Some parameters are not allowed to be changed, # since changing them would simply wreck some chaos not_allowed <- c( - "num_class" - , "metric" - , "boosting" + .PARAMETER_ALIASES()[["num_class"]] + , .PARAMETER_ALIASES()[["metric"]] , .PARAMETER_ALIASES()[["boosting"]] ) if (any(pnames %in% not_allowed)) { diff --git a/R-package/tests/testthat/test_parameters.R b/R-package/tests/testthat/test_parameters.R index 9d6c75c861e5..beedbe452ba6 100644 --- a/R-package/tests/testthat/test_parameters.R +++ b/R-package/tests/testthat/test_parameters.R @@ -48,6 +48,9 @@ expect_true(".PARAMETER_ALIASES() returns a named list", { param_aliases <- .PARAMETER_ALIASES() expect_true(is.list(param_aliases)) expect_true(is.character(names(param_aliases))) + expect_true(is.character(param_aliases[["boosting"]])) + expect_true(is.character(param_aliases[["metric"]])) + expect_true(is.character(param_aliases[["num_class"]])) }) expect_true("training should warn if you use 'dart' boosting, specified with 'boosting' or aliases", { From 7c2c7048fbd021ca1c850f525dfe5dc93915948a Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 23 Oct 2019 23:56:14 -0500 Subject: [PATCH 06/10] more use of shared parameters --- R-package/R/aliases.R | 17 +++++++++++++++++ R-package/R/lgb.cv.R | 16 +++------------- R-package/R/lgb.train.R | 16 +++------------- R-package/tests/testthat/test_parameters.R | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R index 8ae11e87c504..c7ecf8f72410 100644 --- a/R-package/R/aliases.R +++ b/R-package/R/aliases.R @@ -12,6 +12,12 @@ , "boost" , "boosting_type" ) + , "early_stopping_round" = c( + "early_stopping_round" + , "early_stopping_rounds" + , "early_stopping" + , "n_iter_no_change" + ) , "metric" = c( "metric" , "metrics" @@ -21,5 +27,16 @@ "num_class" , "num_classes" ) + , "num_iterations" = c( + "num_iterations" + , "num_iteration" + , "n_iter" + , "num_tree" + , "num_trees" + , "num_round" + , "num_rounds" + , "num_boost_round" + , "n_estimators" + ) )) } diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index 980b712b9148..3a8a57d7c2fe 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -136,17 +136,7 @@ lgb.cv <- function(params = list(), begin_iteration <- predictor$current_iter() + 1 } # Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one - n_trees <- c( - "num_iterations" - , "num_iteration" - , "n_iter" - , "num_tree" - , "num_trees" - , "num_round" - , "num_rounds" - , "num_boost_round" - , "n_estimators" - ) + n_rounds <- .PARAMETER_ALIASES()[["num_iterations"]] if (any(names(params) %in% n_trees)) { end_iteration <- begin_iteration + params[[which(names(params) %in% n_trees)[1]]] - 1 } else { @@ -227,7 +217,7 @@ lgb.cv <- function(params = list(), # If early stopping was passed as a parameter in params(), prefer that to keyword argument # early_stopping_rounds by overwriting the value in 'early_stopping_rounds' - early_stop <- c("early_stopping_round", "early_stopping_rounds", "early_stopping", "n_iter_no_change") + early_stop <- .PARAMETER_ALIASES()[["early_stopping_round"]] early_stop_param_indx <- names(params) %in% early_stop if (any(early_stop_param_indx)) { first_early_stop_param <- which(early_stop_param_indx)[[1]] @@ -238,7 +228,7 @@ lgb.cv <- function(params = list(), # Did user pass parameters that indicate they want to use early stopping? using_early_stopping_via_args <- !is.null(early_stopping_rounds) - boosting_param_names <- c("boosting", .PARAMETER_ALIASES()[["boosting"]]) + boosting_param_names <- .PARAMETER_ALIASES()[["boosting"]] using_dart <- any( sapply( X = boosting_param_names diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index 1900637fcdfc..852ae146c7a2 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -108,17 +108,7 @@ lgb.train <- function(params = list(), begin_iteration <- predictor$current_iter() + 1 } # Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one - n_rounds <- c( - "num_iterations" - , "num_iteration" - , "n_iter" - , "num_tree" - , "num_trees" - , "num_round" - , "num_rounds" - , "num_boost_round" - , "n_estimators" - ) + n_rounds <- .PARAMETER_ALIASES()[["num_iterations"]] if (any(names(params) %in% n_rounds)) { end_iteration <- begin_iteration + params[[which(names(params) %in% n_rounds)[1]]] - 1 } else { @@ -209,7 +199,7 @@ lgb.train <- function(params = list(), # If early stopping was passed as a parameter in params(), prefer that to keyword argument # early_stopping_rounds by overwriting the value in 'early_stopping_rounds' - early_stop <- c("early_stopping_round", "early_stopping_rounds", "early_stopping", "n_iter_no_change") + early_stop <- .PARAMETER_ALIASES()[["early_stopping_round"]] early_stop_param_indx <- names(params) %in% early_stop if (any(early_stop_param_indx)) { first_early_stop_param <- which(early_stop_param_indx)[[1]] @@ -220,7 +210,7 @@ lgb.train <- function(params = list(), # Did user pass parameters that indicate they want to use early stopping? using_early_stopping_via_args <- !is.null(early_stopping_rounds) - boosting_param_names <- c("boosting", .PARAMETER_ALIASES()[["boosting"]]) + boosting_param_names <- .PARAMETER_ALIASES()[["boosting"]] using_dart <- any( sapply( X = boosting_param_names diff --git a/R-package/tests/testthat/test_parameters.R b/R-package/tests/testthat/test_parameters.R index beedbe452ba6..a82fb0df7c6a 100644 --- a/R-package/tests/testthat/test_parameters.R +++ b/R-package/tests/testthat/test_parameters.R @@ -54,7 +54,7 @@ expect_true(".PARAMETER_ALIASES() returns a named list", { }) expect_true("training should warn if you use 'dart' boosting, specified with 'boosting' or aliases", { - for (boosting_param in c("boosting", .PARAMETER_ALIASES()[["boosting"]])){ + for (boosting_param in .PARAMETER_ALIASES()[["boosting"]]){ expect_warning({ result <- lightgbm( data = train$data From 4c785ee87aaf0a9d53b4bf63b87a39d25cb35b03 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 24 Oct 2019 23:33:35 -0500 Subject: [PATCH 07/10] fixed n_rounds vs n_trees --- R-package/R/lgb.cv.R | 2 +- R-package/R/lgb.train.R | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/R-package/R/lgb.cv.R b/R-package/R/lgb.cv.R index 3a8a57d7c2fe..c810432b01ba 100644 --- a/R-package/R/lgb.cv.R +++ b/R-package/R/lgb.cv.R @@ -136,7 +136,7 @@ lgb.cv <- function(params = list(), begin_iteration <- predictor$current_iter() + 1 } # Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one - n_rounds <- .PARAMETER_ALIASES()[["num_iterations"]] + n_trees <- .PARAMETER_ALIASES()[["num_iterations"]] if (any(names(params) %in% n_trees)) { end_iteration <- begin_iteration + params[[which(names(params) %in% n_trees)[1]]] - 1 } else { diff --git a/R-package/R/lgb.train.R b/R-package/R/lgb.train.R index 852ae146c7a2..eb4bef40782e 100644 --- a/R-package/R/lgb.train.R +++ b/R-package/R/lgb.train.R @@ -108,14 +108,13 @@ lgb.train <- function(params = list(), begin_iteration <- predictor$current_iter() + 1 } # Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one - n_rounds <- .PARAMETER_ALIASES()[["num_iterations"]] - if (any(names(params) %in% n_rounds)) { - end_iteration <- begin_iteration + params[[which(names(params) %in% n_rounds)[1]]] - 1 + n_trees <- .PARAMETER_ALIASES()[["num_iterations"]] + if (any(names(params) %in% n_trees)) { + end_iteration <- begin_iteration + params[[which(names(params) %in% n_trees)[1]]] - 1 } else { end_iteration <- begin_iteration + nrounds - 1 } - # Check for training dataset type correctness if (!lgb.is.Dataset(data)) { stop("lgb.train: data only accepts lgb.Dataset object") From 1b6a6b449656ec87da45251b1f59e11a8f5fffa0 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 25 Oct 2019 08:07:13 -0700 Subject: [PATCH 08/10] Update R-package/R/aliases.R Co-Authored-By: Nikita Titov --- R-package/R/aliases.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R index c7ecf8f72410..067a14f8f566 100644 --- a/R-package/R/aliases.R +++ b/R-package/R/aliases.R @@ -3,7 +3,7 @@ # [description] List of respected parameter aliases. Wrapped in a function to take advantage of # lazy evaluation (so it doesn't matter what order R sources files during installation). -# [return] A named list, where each key is a main LightGBM parameter and each value is a character +# [return] A named list, where each key is a main LightGBM parameter and each value is a character # vector of corresponding aliases. .PARAMETER_ALIASES <- function(){ return(list( From 224bc63098547169d7ec42b411e1555fe6b78780 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 25 Oct 2019 08:07:21 -0700 Subject: [PATCH 09/10] Update R-package/R/aliases.R Co-Authored-By: Nikita Titov --- R-package/R/aliases.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R index 067a14f8f566..76d00aff1919 100644 --- a/R-package/R/aliases.R +++ b/R-package/R/aliases.R @@ -1,4 +1,4 @@ -# Central location for paramter aliases. +# Central location for parameter aliases. # See https://lightgbm.readthedocs.io/en/latest/Parameters.html#core-parameters # [description] List of respected parameter aliases. Wrapped in a function to take advantage of From 2c7a43f30cf79c72fc246b2fd99885403a992aa4 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 25 Oct 2019 10:41:47 -0500 Subject: [PATCH 10/10] added unit tests on two more parameter aliases --- R-package/tests/testthat/test_parameters.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R-package/tests/testthat/test_parameters.R b/R-package/tests/testthat/test_parameters.R index a82fb0df7c6a..83aa4ce9f4a9 100644 --- a/R-package/tests/testthat/test_parameters.R +++ b/R-package/tests/testthat/test_parameters.R @@ -49,8 +49,10 @@ expect_true(".PARAMETER_ALIASES() returns a named list", { expect_true(is.list(param_aliases)) expect_true(is.character(names(param_aliases))) expect_true(is.character(param_aliases[["boosting"]])) + expect_true(is.character(param_aliases[["early_stopping_round"]])) expect_true(is.character(param_aliases[["metric"]])) expect_true(is.character(param_aliases[["num_class"]])) + expect_true(is.character(param_aliases[["num_iterations"]])) }) expect_true("training should warn if you use 'dart' boosting, specified with 'boosting' or aliases", {