The PermutationImportance
对象有一些很好的属性,例如feature_importances_
and feature_importances_std_
.
为了以 HTML 样式可视化此属性,我使用了eli5.show_weights
功能。但是,我注意到显示的标准差与中的值不一致feature_importances_std_
.
更具体地说,我可以看到显示的 HTML 值等于feature_importances_std_ * 2
。这是为什么 ?
Code:
from sklearn import datasets
import eli5
from eli5.sklearn import PermutationImportance
from sklearn.svm import SVC, SVR
# import some data to play with
iris = datasets.load_iris()
X = iris.data[:, :2] # we only take the first two features.
y = iris.target
clf = SVC()
perms = PermutationImportance(clf, n_iter=1000, cv=10, random_state=0).fit(X, y)
print(perms.feature_importances_)
# this is the actual SD
print(perms.feature_importances_std_)
# These are the displayed values
print(perms.feature_importances_std_* 2)
[0.39527333 0.17178 ] # the actual mean
[0.13927548 0.11061278] # the actual SD
[0.27855095 0.22122556] # the displayed values by `show_weights()`
eli5.show_weights(perms)
我们可以看到显示的标准差增加了一倍,即2 * perms.feature_importances_std_
.
这可能是一个错误吗?
找到了*2
:
它位于生成下一页中的特征重要性 html 表的模板中
https://github.com/TeamHG-Memex/eli5/blob/63e99182dc682bbf225355c80a24807396a747b6/eli5/templates/feature_importances.html
{% if not fw.std is none %}
± {{ "%0.4f"|format(2 * fw.std) }}
{% endif %}
明明是手写的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)