Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fixing the early stop for maximize = T (#5915)
Browse files Browse the repository at this point in the history
close #4587
  • Loading branch information
Marc Barakat authored and thirdwing committed May 25, 2017
1 parent 132544d commit 7708d80
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 7708d80

Please sign in to comment.