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
aef50f86
Unverified
Commit
aef50f86
authored
Jul 08, 2020
by
Guolin Ke
Committed by
GitHub
Jul 07, 2020
Browse files
[python] fix early_stopping_round = 0 (#3211)
* Update engine.py * Update sklearn.py
parent
1e2013a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+2
-2
python-package/lightgbm/sklearn.py
python-package/lightgbm/sklearn.py
+1
-1
No files found.
python-package/lightgbm/engine.py
View file @
aef50f86
...
@@ -211,7 +211,7 @@ def train(params, train_set, num_boost_round=100,
...
@@ -211,7 +211,7 @@ def train(params, train_set, num_boost_round=100,
elif
isinstance
(
verbose_eval
,
integer_types
):
elif
isinstance
(
verbose_eval
,
integer_types
):
callbacks
.
add
(
callback
.
print_evaluation
(
verbose_eval
))
callbacks
.
add
(
callback
.
print_evaluation
(
verbose_eval
))
if
early_stopping_rounds
is
not
None
:
if
early_stopping_rounds
is
not
None
and
early_stopping_rounds
>
0
:
callbacks
.
add
(
callback
.
early_stopping
(
early_stopping_rounds
,
first_metric_only
,
verbose
=
bool
(
verbose_eval
)))
callbacks
.
add
(
callback
.
early_stopping
(
early_stopping_rounds
,
first_metric_only
,
verbose
=
bool
(
verbose_eval
)))
if
learning_rates
is
not
None
:
if
learning_rates
is
not
None
:
...
@@ -548,7 +548,7 @@ def cv(params, train_set, num_boost_round=100,
...
@@ -548,7 +548,7 @@ def cv(params, train_set, num_boost_round=100,
for
i
,
cb
in
enumerate
(
callbacks
):
for
i
,
cb
in
enumerate
(
callbacks
):
cb
.
__dict__
.
setdefault
(
'order'
,
i
-
len
(
callbacks
))
cb
.
__dict__
.
setdefault
(
'order'
,
i
-
len
(
callbacks
))
callbacks
=
set
(
callbacks
)
callbacks
=
set
(
callbacks
)
if
early_stopping_rounds
is
not
None
:
if
early_stopping_rounds
is
not
None
and
early_stopping_rounds
>
0
:
callbacks
.
add
(
callback
.
early_stopping
(
early_stopping_rounds
,
first_metric_only
,
verbose
=
False
))
callbacks
.
add
(
callback
.
early_stopping
(
early_stopping_rounds
,
first_metric_only
,
verbose
=
False
))
if
verbose_eval
is
True
:
if
verbose_eval
is
True
:
callbacks
.
add
(
callback
.
print_evaluation
(
show_stdv
=
show_stdv
))
callbacks
.
add
(
callback
.
print_evaluation
(
show_stdv
=
show_stdv
))
...
...
python-package/lightgbm/sklearn.py
View file @
aef50f86
...
@@ -602,7 +602,7 @@ class LGBMModel(_LGBMModelBase):
...
@@ -602,7 +602,7 @@ class LGBMModel(_LGBMModelBase):
if
evals_result
:
if
evals_result
:
self
.
_evals_result
=
evals_result
self
.
_evals_result
=
evals_result
if
early_stopping_rounds
is
not
None
:
if
early_stopping_rounds
is
not
None
and
early_stopping_rounds
>
0
:
self
.
_best_iteration
=
self
.
_Booster
.
best_iteration
self
.
_best_iteration
=
self
.
_Booster
.
best_iteration
self
.
_best_score
=
self
.
_Booster
.
best_score
self
.
_best_score
=
self
.
_Booster
.
best_score
...
...
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