xgboost使用小结

一、参考文献:

  xgboost核心手册:https://xgboost.readthedocs.io/en/stable/

  scikit-learn:https://scikit-learn.org/stable/

  两个不错的教学视频:

    https://www.youtube.com/watch?v=GrJP9FLV3FE

    https://www.youtube.com/watch?v=OtD8wVaFm6E

    视频作者Josh Starmer的其他专辑也很精彩:

    a. 机器学习系列: https://www.youtube.com/playlist?list=PLblh5JKOoLUICTaGLRoHQDuF_7q2GfuJF

    b. 深度学习-神经网络系列:https://www.youtube.com/playlist?list=PLblh5JKOoLUIxGDQs4LFFD--41Vzf-ME1

 

其他参考文献:

  1. https://www.jianshu.com/p/9de0f73efc4c   使用Xgboost进行回归

  2. https://zhuanlan.zhihu.com/p/374399558/ 线性回归模型总结

  3. https://zhuanlan.zhihu.com/p/562983875   xgboost详解

  4. https://zhuanlan.zhihu.com/p/389399280 深度学习-回归问题

  5. https://mp.weixin.qq.com/s?__biz=MzA4ODcwOTExMQ==&mid=2655687562&idx=6&sn=704589449b438474928a6d5736c2dc91 7大经典回归问题

  6. https://zhuanlan.zhihu.com/p/546048176?utm_id=0 xgboost常见特征归一化

二、xgboost回归demo

1. 加载样本

data = pd.read_csv("data/tt.csv", header=[0])
data_train = data[0:int(len(data) * 9 / 10)]
data_test = data[int(len(data) * 9 / 10):len(data)]

train_x = np.array(data_train.iloc[:, [i for i in range(data_train.shape[1]-1)]])
train_y = np.array(data_train['col_67'])

test_x = np.array(data_test.iloc[:, [i for i in range(data_test.shape[1]-1)]])
test_y = np.array(data_test['col_67'])

2. 模型参数

xgb_model = xgb.XGBRegressor(
    max_depth=6,
    learning_rate=0.05,
    n_estimators=150,
    objective='reg:squarederror',
    booster='gbtree',
    random_state=0
)

3. 模型拟合/训练

reg_model = xgb_model.fit(train_x, train_y)

4. 模型预测

x_predicted = xgb_model.predict(test_x)
print(x_predicted)

 

 

posted @ 2023-09-26 15:23  ohmygirl  阅读(11)  评论(0编辑  收藏  举报

知识改变命运,码农拯救人生

ohmygirl@2014