ML:LGBMClassifier、XGBClassifier和CatBoostClassifier的feature_importances_计算方法源代码解读之详细攻略
目录
LGBMClassifier、XGBClassifier和CatBoostClassifier的feature_importances_计算方法源代码解读之详细攻略
LGBMClassifier
XGBClassifier
CatBoostClassifier
LGBMClassifier、XGBClassifier和CatBoostClassifier的feature_importances_计算方法源代码解读之详细攻略 LGBMClassifierLGBMClassifier.feature_importances_函数,采用split方式计算
LGBMC.feature_importances_importance_type='split',
def feature_importances_(self): """Get feature importances.
Note ---- Feature importance in sklearn interface used to normalize to 1,it's deprecated after 2.0.4 and is the same as Booster.feature_importance() now. ``importance_type`` attribute is passed to the function to configure the type of importance values to be extracted. """ if self._n_features is None: raise LGBMNotFittedError('No feature_importances found. Need to call fit beforehand.') return self.booster_.feature_importance(importance_type=self.importance_type)
@property def booster_(self): """Get the underlying lightgbm Booster of this model.""" if self._Booster is None: raise LGBMNotFittedError('No booster found. Need to call fit beforehand.') return self._Boosterdef num_feature(self): """Get number of features.
Returns ------- num_feature : int The number of features. """ out_num_feature = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterGetNumFeature( self.handle, ctypes.byref(out_num_feature))) return out_num_feature.value
self.booster_.feature_importance (importance_type=
self.importance_type)
def feature_importance(self, importance_type='split', iteration=None): """Get feature importances.
Parameters ---------- importance_type : string, optional (default="split"). How the importance is calculated. 字符串,可选(默认值=“split”)。如何计算重要性。 If "split", result contains numbers of times the feature is used in a model. 如果“split”,则结果包含该特征在模型中使用的次数。 If "gain", result contains total gains of splits which use the feature.如果“gain”,则结果包含使用该特征的拆分的总增益。 iteration : int or None, optional (default=None).Limit number of iterations in the feature importance calculation. If None, if the best iteration exists, it is used; otherwise, all trees are used. If
- Computer:C语言/C++语言的简介、发展历史、应用领域、编程语言环境IDE安装、学习路线之详细攻略
- DBMS/Database:数据库管理的简介、安装(注意事项等)、学习路线(基于SQLSever深入理解SQL命令语句综合篇《初级→中级→高级》/几十项代码案例集合)之详细攻略
- DayDayUp之Job:牛客网—算法工程师—剑指offer之66道在线编程(解决思路及其代码)——1~20
- High&NewTech:一文了解计算机思维、数学思维的本质区别,以及算法和程序的认知比较
- Algorithm:【Algorithm算法进阶之路】之十大经典排序算法
- DataScience:数据生成之在原始数据上添加小量噪声(可自定义噪声)进而实现构造新数据(dataframe格式数据存储案例)
- CV:Image.open 和cv2.imread的简介、区别及PIL.Image格式/OpenCV格式相互转换代码实现之详细攻略
- Py之shap:shap.explainers.shap_values函数的简介、解读(shap_values[1]索引为1的原因)、使用方法之详细攻略
- Py之PaddleFL:PaddleFL/paddle_fl的简介、安装、使用方法之详细攻略
- Python语言学习:Python语言学习之正则表达式常用函数之re.search方法【输出仅一个匹配结果(内容+位置)】、re.findall方法【输出所有匹配结果(内容)】案例集合之详细攻略