Commit 301e0a7c authored by Guolin Ke's avatar Guolin Ke
Browse files

check num_boost_round in python/R package.

parent 5a89a76d
......@@ -108,6 +108,10 @@ lgb.cv <- function(params = list(),
fobj <- NULL
feval <- NULL
if (nrounds <= 0) {
stop("nrounds should be greater than zero")
}
# Check for objective (function or not)
if (is.function(params$objective)) {
fobj <- params$objective
......
......@@ -83,6 +83,10 @@ lgb.train <- function(params = list(),
fobj <- NULL
feval <- NULL
if (nrounds <= 0) {
stop("nrounds should be greater than zero")
}
# Check for objective (function or not)
if (is.function(params$objective)) {
fobj <- params$objective
......
......@@ -18,7 +18,9 @@ lightgbm <- function(data,
# Set data to a temporary variable
dtrain <- data
if (nrounds <= 0) {
stop("nrounds should be greater than zero")
}
# Check whether data is lgb.Dataset, if not then create lgb.Dataset manually
if (!lgb.is.Dataset(dtrain)) {
dtrain <- lgb.Dataset(data, label = label, weight = weight)
......
......@@ -104,6 +104,8 @@ def train(params, train_set, num_boost_round=100,
warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias))
break
if num_boost_round <= 0:
raise ValueError("num_boost_round should be greater than zero.")
if isinstance(init_model, string_type):
predictor = _InnerPredictor(model_file=init_model)
elif isinstance(init_model, Booster):
......@@ -394,6 +396,8 @@ def cv(params, train_set, num_boost_round=100,
early_stopping_rounds = params.pop(alias)
break
if num_boost_round <= 0:
raise ValueError("num_boost_round should be greater than zero.")
if isinstance(init_model, string_type):
predictor = _InnerPredictor(model_file=init_model)
elif isinstance(init_model, Booster):
......
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