def xgb_Fit(knownX,knownY,preX):
xlf = xgb.XGBRegressor(max_depth=11,
learning_rate=0.01,
n_estimators=301,
silent=True,
objective=mape,
gamma=0,
min_child_weight=5,
max_delta_step=0,
subsample=0.8,
colsample_bytree=0.8,
colsample_bylevel=1,
reg_alpha=1e0,
reg_lambda=0,
scale_pos_weight=1,
seed=9,
missing=None)
x_train, x_test, y_train, y_test = train_test_split(knownX, knownY, test_size=0.5, random_state=1)
for i in range(y_train.shape[1]):
xlf.fit(x_train, y_train[:, i].reshape(-1, 1), eval_metric=mape, verbose=False)
# eval_set=[(x_test, y_test[:, i].reshape(-1, 1))], early_stopping_rounds=2)
tempPre = xlf.predict(preX).reshape(-1, 1)
if i == 0:
Y_pre = tempPre
else:
Y_pre = np.c_[Y_pre, tempPre]
Y_pre = Y_pre.reshape(-1, 1)
return Y_pre
#?model??gridsearch
评论列表
文章目录