Commit ac975e73 authored by Laurae's avatar Laurae Committed by Guolin Ke
Browse files

[R-package] Add best score (#721)

* Try to store best scores in R package Microsoft/LightGBM#686

* Add binding for best_score (unlock environment)

* Fix double comma

* Add best_score to lgb.Booster
parent 402474f4
...@@ -9,6 +9,7 @@ CB_ENV <- R6Class( ...@@ -9,6 +9,7 @@ CB_ENV <- R6Class(
eval_list = list(), eval_list = list(),
eval_err_list = list(), eval_err_list = list(),
best_iter = -1, best_iter = -1,
best_score = -1,
met_early_stop = FALSE met_early_stop = FALSE
) )
) )
...@@ -350,6 +351,7 @@ cb.early.stop <- function(stopping_rounds, verbose = TRUE) { ...@@ -350,6 +351,7 @@ cb.early.stop <- function(stopping_rounds, verbose = TRUE) {
# Check if model is not null # Check if model is not null
if (!is.null(env$model)) { if (!is.null(env$model)) {
env$model$best_score <- best_score[i]
env$model$best_iter <- best_iter[i] env$model$best_iter <- best_iter[i]
} }
......
...@@ -4,6 +4,7 @@ Booster <- R6Class( ...@@ -4,6 +4,7 @@ Booster <- R6Class(
public = list( public = list(
best_iter = -1, best_iter = -1,
best_score = -1,
record_evals = list(), record_evals = list(),
# Finalize will free up the handles # Finalize will free up the handles
......
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