"eli5.show_weights"显示的标准偏差与"feature_importances_std_"中的值不一致 [英] `eli5.show_weights` displayed standard deviation does not agree with the values in `feature_importances_std_`
问题描述
PermutationImportance
对象具有一些不错的属性,例如feature_importances_
和feature_importances_std_
.
The PermutationImportance
object has some nice attributes such as feature_importances_
and feature_importances_std_
.
为了以HTML样式可视化此属性,我使用了eli5.show_weights
函数.但是,我注意到显示的标准偏差与feature_importances_std_
中的值不一致.
To visualize in an HTML style this attributes I used eli5.show_weights
function. However, I noticed that the displayed standard deviation does not agree with the values in feature_importances_std_
.
更具体地说,我可以看到显示的HTML值等于feature_importances_std_ * 2
.为什么会这样?
代码:
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_
.
We can see that the diplayed standard deviation is doupled i.e. 2 * perms.feature_importances_std_
.
这可能是错误吗?
推荐答案
找到了*2
:
在模板中,该页面将在下一页中生成功能重要性html表
Found the *2
:
It's in the template generating the feature importances html table in the following page
{% if not fw.std is none %}
± {{ "%0.4f"|format(2 * fw.std) }}
{% endif %}
显然是手工放置的
这篇关于"eli5.show_weights"显示的标准偏差与"feature_importances_std_"中的值不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!