Skip to content

Commit

Permalink
fixing the early stop for maximize = T (apache#5915)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Barakat authored and thirdwing committed May 25, 2017
1 parent e74ccc9 commit 4cb57d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R-package/R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mx.callback.early.stop <- function(train.metric = NULL, eval.metric = NULL, bad.
if (!is.null(env$metric)) {
if (!is.null(train.metric)) {
result <- env$metric$get(env$train.metric)
if (result$value < train.metric | (maximize == TRUE & result$value > train.metric)) {
if ((maximize == F & result$value < train.metric) | (maximize == TRUE & result$value > train.metric)) {
return(FALSE)
}
}
Expand All @@ -104,7 +104,7 @@ mx.callback.early.stop <- function(train.metric = NULL, eval.metric = NULL, bad.
if (!is.null(eval.metric)) {
if (!is.null(env$eval.metric)) {
result <- env$metric$get(env$eval.metric)
if (result$value < eval.metric | (maximize == TRUE & result$value > eval.metric)) {
if ((maximize == F & result$value < eval.metric) | (maximize == TRUE & result$value > eval.metric)) {
return(FALSE)
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ mx.callback.early.stop <- function(train.metric = NULL, eval.metric = NULL, bad.

result <- env$metric$get(env$eval.metric)

if (result$value > mx.best.score | (maximize == TRUE & result$value < mx.best.score)) {
if ((maximize == F & result$value > mx.best.score) | (maximize == TRUE & result$value < mx.best.score)) {

if (mx.best.iter == bad.steps) {
if (verbose) {
Expand Down

0 comments on commit 4cb57d6

Please sign in to comment.