首页 > 解决方案 > 如何使用排列特征重要性获取值

问题描述

我有一个包含 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_'

你能帮我解决这个错误吗?

标签: machine-learningdeep-learningdata-miningfeature-extractionfeature-selection

解决方案


如果您通过查看 PermutationImportance 对象的属性

ord(perm)

在适合PI对象后,您可以看到所有属性和方法,这意味着您需要执行以下操作:

perm = PermutationImportance(model, random_state=1).fit(X_train,y)

推荐阅读