Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ver 4.0.0: lgb.cv returns a dict whose keys have an extra "valid" prefix #6012

Closed
xinwang0312 opened this issue Jul 27, 2023 · 3 comments
Closed
Labels

Comments

@xinwang0312
Copy link

Description

For the code below, lgb.cv version 3.3.2 gives a dictionary with keys
['binary_logloss-mean', 'binary_logloss-stdv']

but lgb version 4.0.0 gives an output
['valid binary_logloss-mean', 'valid binary_logloss-stdv']

Reproducible example

import lightgbm as lgb
from sklearn.datasets import load_iris
from sklearn.model_selection import KFold



X, y = load_iris(return_X_y=True, as_frame=True)
y = y > 0

data = lgb.Dataset(data=X, label=y)
metric={'name': 'binary_logloss', 'maximize': False}
folds=KFold(n_splits=3, shuffle=True, random_state=23)

params = {'boosting_type': 'gbdt', 'objective': 'binary', 
'verbose': -1, 'feature_pre_filter': False, 'num_leaves': 82, 'max_depth': 8, 
'learning_rate': 0.15543735428541233, 'min_data_in_leaf': 28, 'lambda_l2': 0.04420907265233052}

eval_hist = lgb.cv(
    params, train_set=data, folds=folds, seed=23, metrics='binary_logloss'
)
print(lgb.__version__)
print(eval_hist.keys())

Environment info

4.0.0

Command(s) you used to install LightGBM

conda install -c conda-forge lightgbm

Additional Comments

Screenshot of the result comparsion:
image
image

@jmoralez
Copy link
Collaborator

Hey @xinwang0312, thanks for using LightGBM. This was a breaking changed introduced in #4947 to be consistent with the names of the metrics, previously it would only have the prefix if you set eval_train_metric=True, now it always does. Sorry for the troubles.

@xinwang0312
Copy link
Author

Hi @jmoralez, thanks for the quick reply. I was not aware of it. Will adapt my code to this change.

Copy link

github-actions bot commented Nov 1, 2023

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants