当前位置:网站首页>XGBoost, lightGBM, CatBoost——尝试站在巨人的肩膀上
XGBoost, lightGBM, CatBoost——尝试站在巨人的肩膀上
2022-06-26 02:50:00 【不让人放心】
前言
最近在打科大讯飞的电信客户流失预测挑战赛,赛题为很典型的二分类问题,使用AUC作为评估指标。从官方给的baseline上面学到了好多东西,这里写个总结。
- baseline:https://mp.weixin.qq.com/s/nLgaGMJByOqRVWnm1UfB3g
- 比赛:https://challenge.xfyun.cn/topic/info?type=telecom-customer&ch=ds22-dw-zs01
baseline提供了一种训练策略(KFold),三个Boosting算法(XGBoost, lightGBM,CatBoost),本文主要围绕它们展开。
KFold
k-fold cross-validation,k折交叉验证,初始采样分割成k个子样本,一个单独的子样本被保留作为验证模型的数据,其他k-1个样本用来训练,重复k次,保证每个子样本验证一次,平均k次的结果或者使用其它结合方式,最终得到一个单一的估测值。取k=5,一张图表示:
baseline相当于把这个思路写了一遍,实际上熟悉网格搜索(Grid Search)的同学,在使用sklearn的包时,会注意到**GridSearchCV()**类里面有一个参数cv,这个参数实际上就是在指定交叉验证的折数。采用这种交叉验证的方法,会将所有的数据都参与到训练和预测中,从而有效的避免过学习以及欠学习状态的发生,最后得到的结果也会比较具有说服性。baseline中还有引用StratifiedKFold(虽然并没有使用),该方法是KFold的增强版本,与KFold最大的差异在于StratifiedKFold方法是根据标签y中不同类别占比来进行数据拆分的,能保证分出来的每个折的目标变量具有与整个数据集中相同的比率,比较适用于不平衡的数据集。这次比赛官方给的数据集,训练数据一共150000条,其中正样本75042,几乎是1:1的,非常均衡。
除了k-fold,还有Hold-Out Method(分两组,一组做训练,一组做验证)、Double Cross-Validation(2-fold Cross Validation)、Leave P Out Cross Validation(使用原本样本中的P项来当做验证数据,而剩余的则留下来当做训练数据,重复上述过程)、Shuffle Split(选择一部分数据做训练集,选择一部分做验证集,训练集+验证机的占比之和<=100%)
Boosting
常见的集成学习框架有三种:Bagging,Boosting 和 Stacking。XGBoost、LightGBM和CatBoost都是基于 Boosting 框架的主流集成算法,这哥仨的资料在网上一搜一大把,这里就不赘述了。
XGBoost、LightGBM在使用上它们的语法非常相似,以LightGBM为例:
#lightgbm模型构建和训练
import lightgbm as lgb
d_train = lgb.Dataset(x_train, label=y_train) #训练数据
params = {
}
params['boosting_type'] = 'gbdt'
params['objective'] = 'binary'
params['metric'] = 'auc'
params['learning_rate'] = 0.003
# 此处省略若干参数
model = lgb.train(params, d_train, 50000) #lightgbm模型训练
y_pred=clf.predict(x_test) #模型预测
CatBoost免去了生成Dataset的那一步,使用上确实更接近于sklearn的svm、tree这些常用包:
import catboost
params = {
}
params['boosting_type'] = 'Bernoulli'
params['depth'] =5
params['learning_rate'] = 0.02
# 此处依然省略若干参数
model = catboost.CatBoostRegressor(iterations=20000, **params)
model.fit(x_train, y_train) # 是不是感觉很熟悉??
y_pred = model.predict(x_test)
我个人在拿到数据后,尝试了进行one-hot(分类数据)+normlization(数值型数据),扔到LightGBM里跑,结果AUC不升反降,抱着疑惑,我又进行了一些检索,发现面向机器学习的特征工程,早就有很多的讨论,比如:类别变量,别上来就整one-hot编码,有没有数据标准化(z-score standardization )后效果变差的例子?。后来发现,LightGBM本身在设计上就有针对类别型变量进行优化,自己所做的工作确实称得上是画蛇添足了。只能说封装的越好的模型,里面值得挖掘的点就越多,无论是做特征工程还是调参,都应该抱有敬意。
参考资料
scikit-learn官方文档.sklearn.model_selection.cross_val_score.
jasonfreak.使用sklearn进行集成学习——理论.
那伊抹微笑,等.LightGBM 中文文档.
一种tang两种味.LightGBM算法详解
黄博的机器学习圈子.XGBoost、LightGBM与CatBoost算法对比与调参.
最后的话
最后再引用一下大佬jasonfreak的签名:“一个懒惰的人,总是想设计更智能的程序来避免做重复性工作”。不得不说也是多亏了这些“懒惰的人”,越来越多的智能程序能以这样低的门槛被大众所使用,解决各种复杂的问题。
水平有限,不足之处希望多多指正。
边栏推荐
- Drawing structure diagram with idea
- Record a torture bug caused by restcontrol and controller
- Notes on the 3rd harmonyos training in the studio
- Types and application methods of screen printing
- 2022年挖财证券开户安全嘛?
- 多媒体元素,音频、视频
- OpenAPI 3.0 specification - Food Guide
- 分割、柱子、list
- Add console programs in UE
- Scratch returns 400
猜你喜欢

【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长

Little p weekly Vol.10

【论文笔记】Learning to Grasp with Primitive Shaped Object Policies

Notes on the 3rd harmonyos training in the studio

Additional: brief description of hikaricp connection pool; (I didn't go deep into it, but I had a basic understanding of hikaricp connection pool)

少儿编程对国内传统学科的推进作用
![[reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters](/img/84/2b66b513a0a36464233708fbb4b57d.png)
[reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters

【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina

学习太极创客 — MQTT(四)服务端连接操作
![[solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior](/img/c3/892ce2f45abea7140df98cabc1431b.png)
[solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior
随机推荐
经典模型——NiN&GoogLeNet
【读点论文】FBNetV3: Joint Architecture-Recipe Search using Predictor Pretraining 网络结构和超参数全当训练参数给训练了
stm32Cubemx:看门狗------独立看门狗和窗口看门狗
[solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior
Additional: brief description of hikaricp connection pool; (I didn't go deep into it, but I had a basic understanding of hikaricp connection pool)
Cultivate children's creativity under the concept of project steam Education
文献阅读---优化RNA-seq研究以研究除草剂耐药性(综述)
上传文件/文本/图片,盒子阴影
Qt编译出错ERROR: Unknown module(s) in QT: script
Is it safe to open an online stock account?
《你不可不知的人性》经典语录
golang正则regexp包使用-06-其他用法(特殊字符转换、查找正则共同前缀、切换贪婪模式、查询正则分组个数、查询正则分组名称、用正则切割、查询正则字串)
开通基金账户是安全的吗?怎么申请呢
关于#sql#的问题:SQL问题--账号多地登录的SQL代码
解析社交机器人中的技术变革
todolist未完成,已完成
【论文笔记】Learning to Grasp with Primitive Shaped Object Policies
Camtasia 2022 new ultra clear recording computer video
【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina
Google recommends using kotlin flow in MVVM architecture