skranger
skranger copied to clipboard
Feature importances are all "nan" with 'permutation' importance, and 'oob_error' = False ---- a very simple demonstration
I was having this problem, so I made a very simple test case.
(Note: I get importance values with 'permutation' if oob_error is True, and with other importance types in general.)
Ubuntu 22.04 LTS; Python 3.10
from skranger.ensemble import RangerForestClassifier
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
data = load_iris()
X = data.data
y = data.target
ranger_classifier = RangerForestClassifier(importance = "permutation")
ranger_classifier.fit(X, y)
rf_classifier = RandomForestClassifier()
rf_classifier.fit(X,y)
Debug Window (PyCharm)
ranger_classifier > feature_importances_ = {list: 4} [nan, nan, nan, nan]
> importance = {str} 'permutation'
> importance_mode_ = {int} 3
rf_classifier > feature_importances_ = {ndarray: (4,)} [0.10225579 0.02359158 0.45525929 0.41889333]