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. 模型参数

1
2
3
4
5
6
7
8
xgb_model = xgb.XGBRegressor(
    max_depth=6,
    learning_rate=0.05,
    n_estimators=150,
    objective='reg:squarederror',
    booster='gbtree',
    random_state=0
)

3. 模型拟合/训练

1
reg_model = xgb_model.fit(train_x, train_y)

4. 模型预测

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

 

 

posted @   ohmygirl  阅读(51)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?

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

ohmygirl@2014

点击右上角即可分享
微信分享提示