[scikit-learn] The sum of feature importances !=1

Enhui HUANG gracehuangeh at gmail.com
Tue Jun 21 04:25:04 EDT 2016


Hi,

When I ran the following code:

X, y = make_classification(n_samples=100)
clf = GradientBoostingClassifier(random_state=0).fit(X, y)
imp=clf.feature_importances_
print "The sum of feature importances:", sum(imp)

The sum of feature importances is not always equal to 1. So do you have a
nice explanation for this situation? Besides, if a tree only contains a
root, could we say all its feature importances are 0?  I guess the root
trees will influence sum of feature importances. Is it right?

Best,
Enhui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160621/7360a67d/attachment-0001.html>


More information about the scikit-learn mailing list