Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
301e0a7c
Commit
301e0a7c
authored
Dec 24, 2017
by
Guolin Ke
Browse files
check num_boost_round in python/R package.
parent
5a89a76d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
R-package/R/lgb.cv.R
R-package/R/lgb.cv.R
+4
-0
R-package/R/lgb.train.R
R-package/R/lgb.train.R
+4
-0
R-package/R/lightgbm.R
R-package/R/lightgbm.R
+3
-1
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+4
-0
No files found.
R-package/R/lgb.cv.R
View file @
301e0a7c
...
@@ -107,6 +107,10 @@ lgb.cv <- function(params = list(),
...
@@ -107,6 +107,10 @@ lgb.cv <- function(params = list(),
params
<-
lgb.check.eval
(
params
,
eval
)
params
<-
lgb.check.eval
(
params
,
eval
)
fobj
<-
NULL
fobj
<-
NULL
feval
<-
NULL
feval
<-
NULL
if
(
nrounds
<=
0
)
{
stop
(
"nrounds should be greater than zero"
)
}
# Check for objective (function or not)
# Check for objective (function or not)
if
(
is.function
(
params
$
objective
))
{
if
(
is.function
(
params
$
objective
))
{
...
...
R-package/R/lgb.train.R
View file @
301e0a7c
...
@@ -83,6 +83,10 @@ lgb.train <- function(params = list(),
...
@@ -83,6 +83,10 @@ lgb.train <- function(params = list(),
fobj
<-
NULL
fobj
<-
NULL
feval
<-
NULL
feval
<-
NULL
if
(
nrounds
<=
0
)
{
stop
(
"nrounds should be greater than zero"
)
}
# Check for objective (function or not)
# Check for objective (function or not)
if
(
is.function
(
params
$
objective
))
{
if
(
is.function
(
params
$
objective
))
{
fobj
<-
params
$
objective
fobj
<-
params
$
objective
...
...
R-package/R/lightgbm.R
View file @
301e0a7c
...
@@ -18,7 +18,9 @@ lightgbm <- function(data,
...
@@ -18,7 +18,9 @@ lightgbm <- function(data,
# Set data to a temporary variable
# Set data to a temporary variable
dtrain
<-
data
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
# Check whether data is lgb.Dataset, if not then create lgb.Dataset manually
if
(
!
lgb.is.Dataset
(
dtrain
))
{
if
(
!
lgb.is.Dataset
(
dtrain
))
{
dtrain
<-
lgb.Dataset
(
data
,
label
=
label
,
weight
=
weight
)
dtrain
<-
lgb.Dataset
(
data
,
label
=
label
,
weight
=
weight
)
...
...
python-package/lightgbm/engine.py
View file @
301e0a7c
...
@@ -104,6 +104,8 @@ def train(params, train_set, num_boost_round=100,
...
@@ -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
))
warnings
.
warn
(
"Found `{}` in params. Will use it instead of argument"
.
format
(
alias
))
break
break
if
num_boost_round
<=
0
:
raise
ValueError
(
"num_boost_round should be greater than zero."
)
if
isinstance
(
init_model
,
string_type
):
if
isinstance
(
init_model
,
string_type
):
predictor
=
_InnerPredictor
(
model_file
=
init_model
)
predictor
=
_InnerPredictor
(
model_file
=
init_model
)
elif
isinstance
(
init_model
,
Booster
):
elif
isinstance
(
init_model
,
Booster
):
...
@@ -394,6 +396,8 @@ def cv(params, train_set, num_boost_round=100,
...
@@ -394,6 +396,8 @@ def cv(params, train_set, num_boost_round=100,
early_stopping_rounds
=
params
.
pop
(
alias
)
early_stopping_rounds
=
params
.
pop
(
alias
)
break
break
if
num_boost_round
<=
0
:
raise
ValueError
(
"num_boost_round should be greater than zero."
)
if
isinstance
(
init_model
,
string_type
):
if
isinstance
(
init_model
,
string_type
):
predictor
=
_InnerPredictor
(
model_file
=
init_model
)
predictor
=
_InnerPredictor
(
model_file
=
init_model
)
elif
isinstance
(
init_model
,
Booster
):
elif
isinstance
(
init_model
,
Booster
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment