【发布时间】:2021-01-06 22:46:14
【问题描述】:
我是训练有素的模型,一切正常。我正在计算每个特征权重的排列重要性。我正在使用eli5.show_weights(),但它会将输出显示为html,但我需要将其转换为某种列表或数组,以便我可以访问这些值。
这是我的代码示例,为了简单起见,不包括 estimator's 代码部分:
import eli5
from eli5.sklearn import PermutationImportance
perm = PermutationImportance(estimator, random_state=1).fit(X_testdf, y_testdf)
eli5.show_weights(perm, feature_names = X_testdf.columns.tolist())
这很好用,但我需要将eli5.show_weights(..) 输出的值保存到数组或任何变量中,以便我可以访问这些值。
我也试过了,但没有成功
np.array(eli5.show_weights(perm, feature_names=X.columns.tolist()))
有人可以帮帮我吗?
【问题讨论】:
标签: python numpy scikit-learn permutation logistic-regression