Unverified Commit a6d1f198 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[R-package] Fix custom objective detection in `print.lgb.Booster()` (#4941)

* Update lgb.Booster.R

* Update lgb.cv.R

* Update lgb.train.R

* Update lgb.Booster.R
parent db045f40
......@@ -864,12 +864,13 @@ print.lgb.Booster <- function(x, ...) {
if (obj == "none") {
obj <- "custom"
}
if (x$.__enclos_env__$private$num_class == 1L) {
num_class <- x$.__enclos_env__$private$num_class
if (num_class == 1L) {
cat(sprintf("Objective: %s\n", obj))
} else {
cat(sprintf("Objective: %s (%d classes)\n"
, obj
, x$.__enclos_env__$private$num_class))
, num_class))
}
} else {
cat("(Booster handle is invalid)\n")
......
......@@ -141,7 +141,7 @@ lgb.cv <- function(params = list()
fobj <- NULL
if (is.function(params$objective)) {
fobj <- params$objective
params$objective <- "NONE"
params$objective <- "none"
}
# If eval is a single function, store it as a 1-element list
......
......@@ -109,7 +109,7 @@ lgb.train <- function(params = list(),
fobj <- NULL
if (is.function(params$objective)) {
fobj <- params$objective
params$objective <- "NONE"
params$objective <- "none"
}
# If eval is a single function, store it as a 1-element list
......
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