зеркало из https://github.com/microsoft/LightGBM.git
Update callback.R with keyword arguments (#3430)
see #3390. Also added isTRUE for some of the logical checks, please advise if this is okay
This commit is contained in:
Родитель
5b0ab05c3d
Коммит
0fc4c5c490
|
@ -80,7 +80,7 @@ cb.reset.parameters <- function(new_params) {
|
|||
|
||||
# Check if rounds is null
|
||||
if (is.null(nrounds)) {
|
||||
init(env)
|
||||
init(env = env)
|
||||
}
|
||||
|
||||
# Store iteration
|
||||
|
@ -95,7 +95,7 @@ cb.reset.parameters <- function(new_params) {
|
|||
})
|
||||
|
||||
if (!is.null(env$model)) {
|
||||
env$model$reset_parameter(pars)
|
||||
env$model$reset_parameter(params = pars)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -141,12 +141,12 @@ merge.eval.string <- function(env) {
|
|||
|
||||
# Store evaluation error
|
||||
eval_err <- NULL
|
||||
if (is_eval_err) {
|
||||
if (isTRUE(is_eval_err)) {
|
||||
eval_err <- env$eval_err_list[[j]]
|
||||
}
|
||||
|
||||
# Set error message
|
||||
msg <- c(msg, format.eval.string(env$eval_list[[j]], eval_err))
|
||||
msg <- c(msg, format.eval.string(eval_res = env$eval_list[[j]], eval_err = eval_err))
|
||||
|
||||
}
|
||||
|
||||
|
@ -169,11 +169,11 @@ cb.print.evaluation <- function(period = 1L) {
|
|||
if ((i - 1L) %% period == 0L || is.element(i, c(env$begin_iteration, env$end_iteration))) {
|
||||
|
||||
# Merge evaluation string
|
||||
msg <- merge.eval.string(env)
|
||||
msg <- merge.eval.string(env = env)
|
||||
|
||||
# Check if message is existing
|
||||
if (nchar(msg) > 0L) {
|
||||
cat(merge.eval.string(env), "\n")
|
||||
cat(merge.eval.string(env = env), "\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ cb.record.evaluation <- function() {
|
|||
# Get evaluation data
|
||||
eval_res <- env$eval_list[[j]]
|
||||
eval_err <- NULL
|
||||
if (is_eval_err) {
|
||||
if (isTRUE(is_eval_err)) {
|
||||
eval_err <- env$eval_err_list[[j]]
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ cb.early.stop <- function(stopping_rounds, first_metric_only = FALSE, verbose =
|
|||
|
||||
# Prepare to print if verbose
|
||||
if (verbose) {
|
||||
best_msg[[i]] <<- as.character(merge.eval.string(env))
|
||||
best_msg[[i]] <<- as.character(merge.eval.string(env = env))
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -409,7 +409,7 @@ add.cb <- function(cb_list, cb) {
|
|||
cb_list <- c(cb_list, cb)
|
||||
|
||||
# Set names of elements
|
||||
names(cb_list) <- callback.names(cb_list)
|
||||
names(cb_list) <- callback.names(cb_list = cb_list)
|
||||
|
||||
# Check for existence
|
||||
if ("cb.early.stop" %in% names(cb_list)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче