xgboost相关

xgboost多线程预测的不安全问题

xgboost的predict_proba

官网上说了,predict_proba是一个多线程不安全的方法,主要是因为预测的一个C++代码内部调用的时候有一个PredLoopSpecalize,里面对openmp的thread_temp变量作为类成员变量,在多线程会被当成公共变量修改。说白了就是有预测的内部变量是公共变量。

xgboost特征重要性

如何获取特征重要性:booster中有三种获取方式:
Importance type can be defined as:
‘weight’ - the number of times a feature is used to split the data across all trees.
‘gain’ - the average gain of the feature when it is used in trees
‘cover’ - the average coverage of the feature when it is used in trees
默认是用weight来显示,但是不一定准确
cover: the sum of second order gradient of training data classified to the leaf, if it is square loss, this simply corresponds to the number of instances in that branch. Deeper in the tree a node is, lower this metric will be

XGBoost函数笔记

XGBoost核心代码基于C++开发,训练和预测都是C++代码,外部由Python封装。
最常用的两个类是:

  1. xgboost.XGBClassifier分类器
  2. xgboost.XGBRegressor回归器
    两个类都继承了XGBModel,XGBModel实现了sklearn的接口
    其中分类和回归都是基于booster来完成的,内部有个Booster类,非常重要,每个booset都是一个单独的模型,内部有很多函数,比如get_score,get_dump等函数,都非常有用。booset里面很多函数也是和C代码结合的部分。

booster类别初探

booster有三种选择: gbtree, gblinear or dart.

  1. gbtree 梯度提升树,常用,默认
  2. gblinear就是一个线性分类/回归器
  3. dart 带dropout的

gblinear

利用gblinear训练出的结果就是一个线性分类器

并行化

树内的部可以做并行,在一次分裂之后,子树的分裂可以通过

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值