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训练出的结果就是一个线性分类器

并行化

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,150评论 0 10
  • 一种缘分,结识了简书这个平台,也唤起了我多年不再记事随便涂写的那种欲望。几年后的第一次书写,还望笑纳。 26岁的我...
    Aries_Ni阅读 6,164评论 0 6
  • ---《旧作归档》2009年 此文写于2004年12月24日,今天由此文纪念我的父亲!那个坚强、忍耐、有力的可爱的...
    Andylee阅读 1,755评论 3 4
  • 1、0801今日话题 2、0801晨读感悟 1 0801今日话题 你最近和家人一起吃饭/娱乐是什么时候?你们有多...
    An_An阅读 1,540评论 0 0