当前位置:网站首页>RF、GBDT、XGboost特征选择方法「建议收藏」
RF、GBDT、XGboost特征选择方法「建议收藏」
2022-07-25 20:00:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
RF、GBDT、XGboost都可以做特征选择,属于特征选择中的嵌入式方法。比如在sklearn中,可以用属性feature_importances_去查看特征的重要度, 比如:
from sklearn import ensemble
#grd = ensemble.GradientBoostingClassifier(n_estimators=30)
grd = ensemble.RandomForestClassifier(n_estimators=30)
grd.fit(X_train,y_train)
grd.feature_importances_但是这三个分类器是如何计算出特征的重要度呢?下面来分别的说明一下。
1. 随机森林(Random Forest)
用袋外数据 (OOB) 做预测。随机森林在每次重抽样建立决策树时,都会有一些样本没有被选中,那么就可以用这些样本去做交叉验证,这也是随机森林的优点之一。它可以不用做交叉验证,直接用oob _score_去对模型性能进行评估。
具体的方法就是:
1. 对于每一棵决策树,用OOB 计算袋外数据误差,记为 errOOB1;
2. 然后随机对OOB所有样本的特征i加入噪声干扰,再次计算袋外数据误差,记为errOOB2;
3. 假设有N棵树,特征i的重要性为sum(errOOB2-errOOB1)/N;
如果加入随机噪声后,袋外数据准确率大幅下降,说明这个特征对预测结果有很大的影响,进而说明它的重要程度比较高
2. 梯度提升树(GBDT)
主要是通过计算特征i在单棵树中重要度的平均值,计算公式如下:
其中,M是树的数量。特征i在单棵树的重要度主要是通过计算按这个特征i分裂之后损失的减少值
其中,L是叶子节点的数量,L-1就是非叶子结点的数量。
3. XGboost
XGboost是通过该特征每棵树中分裂次数的和去计算的,比如这个特征在第一棵树分裂1次,第二棵树2次……,那么这个特征的得分就是(1+2+…)。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127541.html原文链接:https://javaforall.cn
边栏推荐
- Application of conductive slip ring in mechanical equipment
- Recommendations on how to install plug-ins and baby plug-ins in idea
- Rainbond插件扩展:基于Mysql-Exporter监控Mysql
- Summarize the level of intelligent manufacturing discussion [macro understanding]
- 10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
- 连接数据库警告 Establishing SSL connection without server‘s identity verification is not recommended.
- Ml programming skills:
- Six axis sensor use learning record
- 03 isomorphism of tree 1
- what is qml in qt
猜你喜欢

PMP practice once a day | don't get lost in the exam -7.25

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC

4. Server startup of source code analysis of Nacos configuration center

手机端触摸图片slider轮播插件photoswipe.js

Creative drop-down multi choice JS plug-in download

基于海思3559 高效率的 0延时 0拷贝 qt播放器方案

Rainbond插件扩展:基于Mysql-Exporter监控Mysql

Binarysearch basic binary search

How does tiktok break zero?
随机推荐
项目中new Promise和async、await中的使用,以及promise.all在项目中的实际应用
Gbase 8s UDR memory management_ 01_ mi_ alloc
From Tong Dai to "Tong Dai" and then to brand, the beauty of sudden profits has changed and remained unchanged
[wp]ctfshow-web入门-爆破
Is there a "fingerprint" in the structure of AAAI 2022 | Gan? Generating network structure from forged image traceability
PMP adopts the latest exam outline, here is [agile project management]
PMP practice once a day | don't get lost in the exam -7.25
Detailed evaluation of current popular redis visual management tools
Siemens PLM Teamcenter download, installation and use tutorial
What is the method to load the torch pre trained model for the mindspore model finetune?
Three skills of interface request merging, and the performance is directly exploded!
Google pixel 6A off screen fingerprint scanner has major security vulnerabilities
网络RTK无人机上机测试[通俗易懂]
Typeerror: 'STR' object is not callable error reason
[Infographics Show] 248 Public Domain Name
各厂商网络虚拟化的优势
基于海思3559 高效率的 0延时 0拷贝 qt播放器方案
Illegal mix of collations for operation ‘UNION‘(bug记录)
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
Wechat applet 10 - wechat template