fix logic

This commit is contained in:
hetong007
2015-05-05 16:44:36 -07:00
parent 54fb49ee5c
commit 0f182b0b66
3 changed files with 61 additions and 2 deletions

View File

@@ -139,11 +139,11 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
params = append(params, list(...))
# Early stopping
if (!is.null(feval) && is.null(maximize))
if (!is.null(feval) && is.null(maximize) && !is.null(earlyStopRound))
stop('Please set maximize to note whether the model is maximizing the evaluation or not.')
if (length(watchlist) == 0 && !is.null(earlyStopRound))
stop('For early stopping you need at least one set in watchlist.')
if (is.null(maximize) && is.null(params$eval_metric))
if (is.null(maximize) && is.null(params$eval_metric) && !is.null(earlyStopRound))
stop('Please set maximize to note whether the model is maximizing the evaluation or not.')
if (is.null(maximize))
{