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
2f984f3a
"src/git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "0dcd422a147ea330431d713118ce19f9bd1f1c9e"
Commit
2f984f3a
authored
Oct 29, 2016
by
Allard van Mossel
Committed by
Guolin Ke
Oct 29, 2016
Browse files
Fixed bug when num_iterations > early_stopping_round (#50)
parent
b24190a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+5
-5
No files found.
src/boosting/gbdt.cpp
View file @
2f984f3a
...
...
@@ -217,9 +217,9 @@ void GBDT::Train() {
}
}
// close file
i
f
(
early_stopping_round_
>
0
)
{
// save
remaining
models
for
(
int
iter
=
gbdt_config_
->
num_iterations
-
early_stopping_round_
;
iter
<
static_cast
<
int
>
(
models_
.
size
());
++
iter
){
i
nt
remaining_models
=
gbdt_config_
->
num_iterations
-
early_stopping_round_
;
if
(
early_stopping_round_
>
0
&&
remaining
_
models
>
0
)
{
for
(
int
iter
=
remaining_models
;
iter
<
static_cast
<
int
>
(
models_
.
size
());
++
iter
){
fprintf
(
output_model_file
,
"Tree=%d
\n
"
,
iter
);
fprintf
(
output_model_file
,
"%s
\n
"
,
models_
.
at
(
iter
)
->
ToString
().
c_str
());
}
...
...
@@ -254,7 +254,7 @@ bool GBDT::OutputMetric(int iter) {
score_t
test_score_
=
valid_metrics_
[
i
][
j
]
->
PrintAndGetLoss
(
iter
,
valid_score_updater_
[
i
]
->
score
());
if
(
!
ret
&&
early_stopping_round_
>
0
){
bool
the_bigger_the_better_
=
valid_metrics_
[
i
][
j
]
->
the_bigger_the_better
;
if
(
best_score_
[
i
][
j
]
<
0
if
(
best_score_
[
i
][
j
]
<
0
||
(
!
the_bigger_the_better_
&&
test_score_
<
best_score_
[
i
][
j
])
||
(
the_bigger_the_better_
&&
test_score_
>
best_score_
[
i
][
j
])){
best_score_
[
i
][
j
]
=
test_score_
;
...
...
@@ -390,7 +390,7 @@ void GBDT::FeatureImportance(const int last_iter) {
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
(),
[](
const
std
::
pair
<
size_t
,
std
::
string
>&
lhs
,
const
std
::
pair
<
size_t
,
std
::
string
>&
rhs
)
{
return
lhs
.
first
>
rhs
.
first
;
return
lhs
.
first
>
rhs
.
first
;
});
// write to model file
fprintf
(
output_model_file
,
"
\n
feature importances:
\n
"
);
...
...
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