当前位置:网站首页>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的签名:“一个懒惰的人,总是想设计更智能的程序来避免做重复性工作”。不得不说也是多亏了这些“懒惰的人”,越来越多的智能程序能以这样低的门槛被大众所使用,解决各种复杂的问题。
水平有限,不足之处希望多多指正。
边栏推荐
- 拖放
- 《你不可不知的人性》经典语录
- How to delete gridlines in ggplot2 (with examples)
- I am in Zhongshan. Where can I open an account? Is it safe to open an account online?
- Golang regexp package use - 06 - other usage (Special Character conversion, find regular Common prefix, Switch gourmand mode, query regular Group NUMBER, query regular Group name, cut with regular, qu
- todolist未完成,已完成
- Matlab| short term load forecasting of power system based on BP neural network
- Network PXE starts winpe and supports UEFI and legacy boot
- 分割、柱子、list
- 培育项目式Steam教育理念下的儿童创造力
猜你喜欢

Utonmos adheres to the principle of "collection and copyright" to help the high-quality development of traditional culture

How Inkscape converts PNG pictures to SVG pictures without distortion

Lumen Analysis and Optimization of ue5 global Lighting System
![[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

The role of children's programming in promoting traditional disciplines in China

Analysis and optimization of ue5 global illumination system lumen

MySQL开发环境

Add console programs in UE

【解决】CMake was unable to find a build program corresponding to “Unix Makefiles“.

What can Arthas do for you?
随机推荐
P2483-[模板]k短路/[SDOI2010]魔法猪学院【主席树,堆】
用元分析法驱动教育机器人的发展
Is it safe to open an account in flush online? How to open a brokerage account online
在哪里开基金帐户安全?
Using meta analysis to drive the development of educational robot
【论文笔记】Manufacturing Control in Job Shop Environments with Reinforcement Learning
The role of children's programming in promoting traditional disciplines in China
Analysis on the diversification of maker space mechanism construction
浅谈虚拟内存与项目开发中的OOM问题
Oracle connectivity issues and Solutions
Arthas(阿尔萨斯) 能为你做什么?
【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina
Lumen Analysis and Optimization of ue5 global Lighting System
国信金太阳靠谱吗?开证券账户安全吗?
力扣(LeetCode)176. 第二高的薪水(2022.06.25)
Leetcode 176 The second highest salary (June 25, 2022)
少儿编程对国内传统学科的推进作用
[flask introduction series] flask processing request and response
[QT] custom control - air quality dashboard
图扑软件数字孪生海上风电 | 向海图强,奋楫争先