python - xgboost 及其 sklearn 的集成 feature_importances_ 错误

标签 python scikit-learn xgboost

我正在使用 XGBoost 及其 sklearn 的包装器。

每当我尝试打印 feature_importances_ 时,都会出现以下错误:

ValueError: invalid literal for int() with base 10

深入研究代码,我发现 feature_importances_ property正在调用 get_fscore method (带有空参数)来自原始助推器。此方法显式返回一个形状如下的字典:

{'feat_name1':5,'feat_name2':8,...,'feat_nameN':1}

因此,考虑到 feature_importances_int 转换应用于 key ,可以揭示错误消息的基本原理。

keys = [int(k.replace('f', '')) for k in fs.keys()] #this is the conflictive line of code

所以,我的问题有两个方面:

1- 这是一个错误吗,因此我应该报告它(甚至修复它并请求拉取)?

2- get_fscore 函数及其 fmap 参数是否遗漏了什么?

最佳答案

我建议在 XGBoost Github 站点将其作为错误报告:https://github.com/dmlc/xgboost/issues

关于python - xgboost 及其 sklearn 的集成 feature_importances_ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36216986/

相关文章:

python - 查找元组列表中具有相同第一项和第三项的元组的计数

python - 在Python中解析带有嵌套列表的字典列表中的值

python - 使用 scikit-learn 计算 AUC 的正确方法是什么?

python - 这是从 Twisted 进行线程化 SQLAlchemy 查询的可接受方式吗?

python - Scikit-learn - 使用 RFECV 和 GridSearch 减少特征。系数存储在哪里?

pandas - 了解scikit学习ValueError : setting an array element with a sequence due to data shape

python-2.7 - 如何从 Github 导入 Xgboost 包到 Windows 7 上的 python 2.7?

python - 如何为 xgboost 实现增量训练?

python - XGBClassifier 很慢,尽管传递了详细参数,但不打印任何输出

python - 从远程服务器中提取大量数据到 DataFrame 中