数据
train_x, test_x, train_y, test_y = train_test_split(data, target, shuffle = True, random_state = 2019)
X_train = train_x.values
X_test = test_x.values
y_train = train_y.values
y_test = test_y.values
方式一:直接跑
params = {
'boosting_type': 'gbdt',
'objective': 'multiclass',
'num_class': 7,
'metric': 'multi_error',
'num_leaves': 120,
'min_data_in_leaf': 100,
'learning_rate': 0.06,
'feature_fraction': 0.8,
'bagging_fraction': 0.8,
'bagging_freq': 5,
'lambda_l1': 0.4,
'lambda_l2': 0.5,
'min_gain_to_split': 0.2,
'verbose': -1,
}
print('Training...')
trn_data = lgb.Dataset(X_train, y_train)
val_data &#