【AI实战】XGBRegressor模型加速训练,使用GPU秒级训练XGBRegressor

XGBRegressor模型加速训练,使用GPU秒级训练XGBRegressor

  • 机器学习模型

      XGBRegressor
    
  • 环境

    • Ubuntu 18.04
    • python3.6.9
    • TensorFlow 2.4.2
    • cuda 11.0
    • xgboost 1.5.2
  • 核心代码

    x, y = load_data()
    model = xgb.XGBRegressor(learning_rate=0.05,
                             n_estimators=420,
                             max_depth=3,
                             min_child_weight=1,
                             gamma=0.0,
                             subsample=0.8,
                             colsample_bytree=0.8,
                             scale_pos_weight=0.8,
                             seed=42,
                             tree_method='gpu_hist',
                             gpu_id=3)
    
	output = model.fit(x, y)

在2百万级的数据上耗时 34.344 s:

real    0m34.344s
user    4m46.866s
sys     0m22.178s

其中,重要的参数:

	tree_method='gpu_hist'
	gpu_id=3 表示使用第3块gpu

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2022年6月9日
下一篇 2022年6月9日

相关推荐