当前位置:网站首页>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
边栏推荐
- 10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
- 【好书推荐】-- 《以太网权威指南》(第2版)
- 导电滑环在机械设备方面的应用
- 创意下拉多选js插件下载
- [good book recommendation] - authoritative guide to Ethernet (2nd Edition)
- Six axis sensor use learning record
- Oracle database download, installation, use tutorial and problem summary
- Skiing mobile H5 game source code download
- Advantages of network virtualization of various manufacturers
- 飞行器pid控制(旋翼飞控)
猜你喜欢

When AI encounters life and health, Huawei cloud builds three bridges for them

JVM(二十三) -- JVM运行时参数

Creative drop-down multi choice JS plug-in download

919. Complete binary tree inserter

Deeplobv1 and V2

各厂商网络虚拟化的优势

创意下拉多选js插件下载

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

Shopping guide for high-end flagship projectors: dangbei X3 pro and dangbei F5 are more immersive!

Security Basics 4 - regular expressions
随机推荐
导电滑环在机械设备方面的应用
Js分页插件支持表格、列表、文本、图像
On interface encryption
How to ensure the quality of customized slip rings
Error when creating dataset with mindscore
UNET and mask RCNN
Interpretation of repartitioned network structure in repvgg network [with code]
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
JVM (XXIII) -- JVM runtime parameters
CarSim simulation quick start (XV) - ADAS sensor objects of CarSim sensor simulation (1)
[good book recommendation] - authoritative guide to Ethernet (2nd Edition)
[Infographics Show] 248 Public Domain Name
Skiing mobile H5 game source code download
LP dual currency pledge liquidity mining DAPP system development logic analysis
[wp]ctfshow-web introductory information collection
Mindspore1.1.1 source code compilation and installation -- errors in the core compilation stage
笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
PMP adopts the latest exam outline, here is [agile project management]
滑雪手机端H5小游戏源码下载
Recommended system topic | Minet: cross domain CTR prediction