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
32a5dbea
Unverified
Commit
32a5dbea
authored
Aug 22, 2023
by
James Lamb
Committed by
GitHub
Aug 22, 2023
Browse files
[python-package] remove CVBooster._append() (#6057)
parent
4ea170f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+5
-9
No files found.
python-package/lightgbm/engine.py
View file @
32a5dbea
...
...
@@ -339,16 +339,12 @@ class CVBooster:
with
open
(
model_file
,
"r"
)
as
file
:
self
.
_from_dict
(
json
.
load
(
file
))
def
_append
(
self
,
booster
:
Booster
)
->
None
:
"""Add a booster to CVBooster."""
self
.
boosters
.
append
(
booster
)
def
_from_dict
(
self
,
models
:
Dict
[
str
,
Any
])
->
None
:
"""Load CVBooster from dict."""
self
.
best_iteration
=
models
[
"best_iteration"
]
self
.
boosters
=
[]
for
model_str
in
models
[
"boosters"
]:
self
.
_
append
(
Booster
(
model_str
=
model_str
))
self
.
boosters
.
append
(
Booster
(
model_str
=
model_str
))
def
_to_dict
(
self
,
num_iteration
:
Optional
[
int
],
start_iteration
:
int
,
importance_type
:
str
)
->
Dict
[
str
,
Any
]:
"""Serialize CVBooster to dict."""
...
...
@@ -514,11 +510,11 @@ def _make_n_folds(
train_set
,
valid_set
,
tparam
=
fpreproc
(
train_set
,
valid_set
,
params
.
copy
())
else
:
tparam
=
params
cv
booster
=
Booster
(
tparam
,
train_set
)
booster
_for_fold
=
Booster
(
tparam
,
train_set
)
if
eval_train_metric
:
cv
booster
.
add_valid
(
train_set
,
'train'
)
cv
booster
.
add_valid
(
valid_set
,
'valid'
)
ret
.
_
append
(
cv
booster
)
booster
_for_fold
.
add_valid
(
train_set
,
'train'
)
booster
_for_fold
.
add_valid
(
valid_set
,
'valid'
)
ret
.
boosters
.
append
(
booster
_for_fold
)
return
ret
...
...
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