python xgboost输出变量重要性_python – 如何计算XGBoost包中的功能得分(/ important)?...

命令xgb.importance返回由f分数测量的特征重要性图.

这个f分数代表什么,如何计算?

解决方法:

它是您可以获得的基本功能重要性指标.

即这个变量分裂了多少次?

此方法的代码显示它只是在所有树中添加给定特征的存在.

def get_fscore(self, fmap=''):

"""Get feature importance of each feature.

Parameters

----------

fmap: str (optional)

The name of feature map file

"""

trees = self.get_dump(fmap) ## dump all the trees to text

fmap = {}

for tree in trees: ## loop through the trees

for line in tree.split('\n'): # text processing

arr = line.split('[')

if len(arr) == 1: # text processing

continue

fid = arr[1].split(']')[0] # text processing

fid = fid.split('

if fid not in fmap: # if the feature id hasn't been seen yet

fmap[fid] = 1 # add it

else:

fmap[fid] += 1 # else increment it

return fmap # return the fmap, which has the counts of each time a variable was split on

标签:xgboost,python,r,classification,feature-selection

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值