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
4feee28a
Unverified
Commit
4feee28a
authored
Dec 17, 2024
by
Claudio Salvatore Arcidiacono
Committed by
GitHub
Dec 17, 2024
Browse files
[python-package] Rename `cvfolds` variable into `cvbooster` in `engine.cv` function (#6762)
parent
480600b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
python-package/lightgbm/engine.py
python-package/lightgbm/engine.py
+10
-10
No files found.
python-package/lightgbm/engine.py
View file @
4feee28a
...
...
@@ -758,7 +758,7 @@ def cv(
train_set
.
_update_params
(
params
).
_set_predictor
(
predictor
)
results
=
defaultdict
(
list
)
cv
folds
=
_make_n_folds
(
cv
booster
=
_make_n_folds
(
full_data
=
train_set
,
folds
=
folds
,
nfold
=
nfold
,
...
...
@@ -802,7 +802,7 @@ def cv(
for
cb
in
callbacks_before_iter
:
cb
(
callback
.
CallbackEnv
(
model
=
cv
folds
,
model
=
cv
booster
,
params
=
params
,
iteration
=
i
,
begin_iteration
=
0
,
...
...
@@ -810,8 +810,8 @@ def cv(
evaluation_result_list
=
None
,
)
)
cv
folds
.
update
(
fobj
=
fobj
)
# type: ignore[call-arg]
res
=
_agg_cv_result
(
cv
folds
.
eval_valid
(
feval
))
# type: ignore[call-arg]
cv
booster
.
update
(
fobj
=
fobj
)
# type: ignore[call-arg]
res
=
_agg_cv_result
(
cv
booster
.
eval_valid
(
feval
))
# type: ignore[call-arg]
for
_
,
key
,
mean
,
_
,
std
in
res
:
results
[
f
"
{
key
}
-mean"
].
append
(
mean
)
results
[
f
"
{
key
}
-stdv"
].
append
(
std
)
...
...
@@ -819,7 +819,7 @@ def cv(
for
cb
in
callbacks_after_iter
:
cb
(
callback
.
CallbackEnv
(
model
=
cv
folds
,
model
=
cv
booster
,
params
=
params
,
iteration
=
i
,
begin_iteration
=
0
,
...
...
@@ -828,14 +828,14 @@ def cv(
)
)
except
callback
.
EarlyStopException
as
earlyStopException
:
cv
folds
.
best_iteration
=
earlyStopException
.
best_iteration
+
1
for
bst
in
cv
folds
.
boosters
:
bst
.
best_iteration
=
cv
folds
.
best_iteration
cv
booster
.
best_iteration
=
earlyStopException
.
best_iteration
+
1
for
bst
in
cv
booster
.
boosters
:
bst
.
best_iteration
=
cv
booster
.
best_iteration
for
k
in
results
:
results
[
k
]
=
results
[
k
][:
cv
folds
.
best_iteration
]
results
[
k
]
=
results
[
k
][:
cv
booster
.
best_iteration
]
break
if
return_cvbooster
:
results
[
"cvbooster"
]
=
cv
folds
# type: ignore[assignment]
results
[
"cvbooster"
]
=
cv
booster
# type: ignore[assignment]
return
dict
(
results
)
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