树模型中的特征重要性(feature_importances_)

本文探讨了决策树、XGBoost和LightGBM中特征重要性的计算和理解。在决策树中,特征重要性基于信息增益或基尼指数的减少。XGBoost的特征重要性依赖于booster类型,如'gbtree',并可通过'importance_type'参数设置计算方式。LightGBM的特征重要性可选择'split'或'gain'进行度量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Decision Tree

  • 该特征带来的标准(信息增益、基尼指数)减少的总和(需要经过标准化). 也被称为基尼重要性.
  • sklearn官网说明原文如下:

The importance of a feature is computed as the (normalized) total reduction of the criterion brought by that feature. It is also known as the Gini importance.

XGBoost

  • 只有当树模型作为基学习器时Feature importance才被定义(booster=gbtree),其他如线性学习器(booster=gblinear)则没有该定义。
  • 参数importance_type(string, default “gain”), 其他取值有“weight”, “cover”, “total_gain” or “total_cover”.
  • weight:该特征被选为分裂特征的次数; gain: 该特征在它所有分裂使用中带来的平均增益; total_gain: 该特征在它所有分裂使用中带来的增益和; cover: 该特征在它所有分裂使用中的平均覆盖率(覆盖率:受分裂影响的样本数); total_cover: 该特征在它所有分裂使用中的总覆盖率.
  • xgboost python API文档地址: XGBoost Python API Reference
  • xgboost 参数完整文档github地址: XGBoost Parameters
  • xgboost文档原文引用:

”weight” is the number of times a feature appears in a tree
”gain” is the average gain of splits which use the feature
”cover” is the average coverage of splits which use the feature where coverage is defined as the number of samples affected by the split

LightGBM

  • 参数importance_type (string, optional (default=‘split’))
  • split: 该特征在模型中被使用的次数; gain: 同xgboost的total_gain.
  • lightgbm python API文档地址:LightGBM Python API
  • lightgbm文档原文引用:

If ‘split’, result contains numbers of times the feature is used in a model. If ‘gain’, result contains total gains of splits which use the feature.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值