我正在使用 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/