我在使用Optuna调整模型时收到以下警告。请告诉我如何抑制这些警告?
[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
我不熟悉Optuna,但我使用Python/lightgbm遇到了这个问题。
从v3.3.2开始,参数调整页面中包含的参数似乎已重命名、弃用或重复。但是,如果您坚持设置/调整模型对象中指定的参数,则可以避免此警告。
from lightgbm import LGBMRegressor
params = LGBMRegressor().get_params()
print(params)
这些是您要设置的唯一参数。如果你想包括所有的参数,你可以做如下的事情。
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)
代码在每个似乎重复的参数对中设置一个或另一个。现在,当您调用lgr.fit(X, y)
时,不应该收到警告。