5

I am getting below warnings while I am using Optuna to tune my model. Please tell me how to suppress these warnings?

[LightGBM] [Warning] feature_fraction is set=0.2, colsample_bytree=1.0 will be ignored. Current value: feature_fraction=0.2
[LightGBM] [Warning] min_data_in_leaf is set=5400, min_child_samples=20 will be ignored. Current value: min_data_in_leaf=5400
[LightGBM] [Warning] min_gain_to_split is set=13.203719815769512, min_split_gain=0.0 will be ignored. Current value: min_gain_to_split=13.203719815769512
Flavia Giammarino
  • 7,987
  • 11
  • 30
  • 40
ffl
  • 91
  • 1
  • 4
  • Could you show your code? – ferdy Nov 25 '21 at 12:11
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 29 '21 at 13:36
  • 2
    Why would you like to ignore it? Variables such as `colsample_bytree` (from the first warning) are default variables that are defined in the LGBM class. `feature_fraction` is just it's alias. So if you'd rename the variable to `colsample_bytree`, there would be no warning. And it won't change the outcome of the coding. Same goes for other warnings such as this one. – Rafa Dec 01 '21 at 11:02

1 Answers1

2

I am not familiar with Optuna but I ran into this issue using Python/lightgbm.

As of v3.3.2, the parameters tuning page included parameters that seem to be renamed, deprecated, or duplicative. If, however, you stick to setting/tuning the parameters specified in the model object you can avoid this warning.

from lightgbm import LGBMRegressor
params = LGBMRegressor().get_params()
print(params)

These are the only parameters you want to set. If you want to be able to include all the parameters, you could do something like below.

from lightgbm import LGBMRegressor
lgr = LGBMRegressor()
params = lgr.get_params()
aliases = [
    {'min_child_weight', 'min_sum_hessian_in_leaf'},
    {'min_child_samples', 'min_data_in_leaf'},
    {'colsample_bytree', 'feature_fraction'},
    {'subsample', 'bagging_fraction'}
]
for alias in aliases:
    if len(alias & set(params)) == 2:
        arg = random.choice(sorted(alias))
        params[arg] = None
lgr = LGBMRegressor(**params)

The code sets one or the other in each parameter pair that seems to be duplicative. Now, when you call lgr.fit(X, y) you should not get the warning.

sedeh
  • 7,083
  • 6
  • 48
  • 65