From 4feee28a53b7b04e66ee09103d2aac260404b9cf Mon Sep 17 00:00:00 2001 From: Claudio Salvatore Arcidiacono <22871978+ClaudioSalvatoreArcidiacono@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:57:35 +0100 Subject: [PATCH] [python-package] Rename `cvfolds` variable into `cvbooster` in `engine.cv` function (#6762) --- python-package/lightgbm/engine.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python-package/lightgbm/engine.py b/python-package/lightgbm/engine.py index dca6b607cdc7..20dfc62b8856 100644 --- a/python-package/lightgbm/engine.py +++ b/python-package/lightgbm/engine.py @@ -758,7 +758,7 @@ def cv( train_set._update_params(params)._set_predictor(predictor) results = defaultdict(list) - cvfolds = _make_n_folds( + cvbooster = _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=cvfolds, + model=cvbooster, params=params, iteration=i, begin_iteration=0, @@ -810,8 +810,8 @@ def cv( evaluation_result_list=None, ) ) - cvfolds.update(fobj=fobj) # type: ignore[call-arg] - res = _agg_cv_result(cvfolds.eval_valid(feval)) # type: ignore[call-arg] + cvbooster.update(fobj=fobj) # type: ignore[call-arg] + res = _agg_cv_result(cvbooster.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=cvfolds, + model=cvbooster, params=params, iteration=i, begin_iteration=0, @@ -828,14 +828,14 @@ def cv( ) ) except callback.EarlyStopException as earlyStopException: - cvfolds.best_iteration = earlyStopException.best_iteration + 1 - for bst in cvfolds.boosters: - bst.best_iteration = cvfolds.best_iteration + cvbooster.best_iteration = earlyStopException.best_iteration + 1 + for bst in cvbooster.boosters: + bst.best_iteration = cvbooster.best_iteration for k in results: - results[k] = results[k][: cvfolds.best_iteration] + results[k] = results[k][: cvbooster.best_iteration] break if return_cvbooster: - results["cvbooster"] = cvfolds # type: ignore[assignment] + results["cvbooster"] = cvbooster # type: ignore[assignment] return dict(results)