我有一个5K(和60个特征)记录的数据集,主要用于二进制分类。
请注意,此solution在这里不起作用
我正在尝试使用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_'
您能帮我解决此错误吗?
答案 0 :(得分:1)
如果通过
查看PermutationImportance对象的属性,ord(perm)
适合PI对象后,您可以查看所有属性和方法但,这意味着您需要执行以下操作:
perm = PermutationImportance(model, random_state=1).fit(X_train,y)