首先定义要优化的目标:
#定义要优化的目标
def LGB_L1_bayesian(num_leaves, learning_rate, feature_fraction,
lambda_l1, lambda_l2, max_depth, bagging_fraction, bagging_freq):
# LightGBM expects next three parameters need to be integer. So we make them integer
num_leaves = int(num_leaves)
max_depth = int(max_depth)
bagging_freq = int(bagging_freq)
assert type(num_leaves) == int
assert type(max_depth) == int
assert type(bagging_freq) == int
param = {
'num_leaves': num_leaves,
'learning_rate': learning_rate,
'bagging_fraction': bagging_fraction,
'bagging_freq': bagging_freq,
'feature_fraction': feature_fraction,
'lambda_l1': lambda_l1,
'lambda_l2': lambda_l2,
'max_depth': max_depth,
'save_binary': True,