FeatureEngineering.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:GZ_travelTime 作者: zhilonglu 项目源码 文件源码
def xgb_Fit(knownX,knownY,preX):
    xlf = xgb.XGBRegressor(max_depth=7,#11
                           learning_rate=0.06,#0.01
                           n_estimators=1000,
                           silent=True,
                           objective=mapeobj,
                           gamma=0,
                           min_child_weight=5,
                           max_delta_step=0,
                           subsample=1,#0.8
                           colsample_bytree=0.8,
                           colsample_bylevel=1,
                           reg_alpha=1e0,
                           reg_lambda=0,
                           scale_pos_weight=1,
                           seed=1850,
                           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))
        # print('Training Error: {:.3f}'.format(1 - xlf.score(x_train,y_train[:,i].reshape(-1,1))))
        # print('Validation Error: {:.3f}'.format(1 - xlf.score(x_test,y_test[:,i].reshape(-1,1))))
        #predict value for output
        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

#sklearn???????
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号