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

[python-package] Booster.refit() raises a misleading warning when using categorical features #6793

Open
jameslamb opened this issue Jan 20, 2025 · 2 comments

Comments

@jameslamb
Copy link
Collaborator

Description

Seeing this warning in Python unit tests:

tests/python_package_test/test_engine.py::test_linear_trees
/Users/runner/miniforge/envs/test-env/lib/python3.12/site-packages/lightgbm/basic.py:2137: UserWarning: categorical_feature keyword has been found in params and will be ignored.
Please use categorical_feature argument of the Dataset constructor to pass this parameter.
_log_warning(

That test case is not directly passing categorical_feature through params... that might be happening internal to lightgbm, and therefore something that users cannot avoid.

Reproducible example

I haven't not narrowed it down further yet, but can reliably reproduce it via running the tests.

pytest 'tests/python_package_test/test_engine.py::test_linear_trees'

Environment info

LightGBM version or commit hash: 226e7f7

Command(s) you used to install LightGBM

cmake -B build -S . -DUSE_OPENMP=OFF
cmake --build build --target _lightgbm -j4
sh build-python.sh install --precompile

Additional Comments

I suspect that maybe this is a result of categorical_feature being treated as both a "param" here:

if self.params is not None:
# no min_data, nthreads and verbose in this function
dataset_params = _ConfigAliases.get(
"bin_construct_sample_cnt",
"categorical_feature",

But also being a keyword argument to Dataset.__init__():

categorical_feature: _LGBM_CategoricalFeatureConfiguration = "auto",

@KekmaTime
Copy link

@jameslamb i would like to work on this issue

@jameslamb
Copy link
Collaborator Author

Sure, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants