machine-learning - 如何使用排列特征重要性获取值
问题描述
我有一个包含 5K(和 60 个特征)记录的数据集,专注于二进制分类。
请注意,此解决方案在这里不起作用
我正在尝试使用Permutation Feature Importance
. 但是,我收到以下错误。你能看看我的代码,让我知道我是否犯了任何错误吗?
import eli5
from eli5.sklearn import PermutationImportance
logreg =LogisticRegression()
model = logreg.fit(X_train_std, y_train)
perm = PermutationImportance(model, random_state=1)
eli5.show_weights(perm, feature_names = X.columns.tolist())
我收到如下所示的错误
AttributeError: 'PermutationImportance' object has no attribute 'feature_importances_'
你能帮我解决这个错误吗?
解决方案
如果您通过查看 PermutationImportance 对象的属性
ord(perm)
在适合PI对象后,您可以看到所有属性和方法,这意味着您需要执行以下操作:
perm = PermutationImportance(model, random_state=1).fit(X_train,y)
推荐阅读
- reactjs - 如何在反应中修复“未处理的拒绝(TypeError):state.categories.concat 不是函数”?
- javascript - SAPUI5 - 存在异步函数时的路由问题
- machine-learning - 图像识别图像中同心环编码目标的检测
- r - R中只有一个变量的堆积条形图(百分比)?
- c# - 以编程方式将 TextBox 置于编辑模式
- python - 如果任何步骤的测试失败,如何将测试结果发送到 testrail?
- puppet - 在 puppet 中表达数字系列
- symfony - 在作曲家安装期间运行 Symfony 4 flex 控制台命令脚本
- ssl - 如何在 Kubernetes 的 pod-to-service 调用中轻松启用 SSL
- python - Python - 分组依据和过滤属性值缺失