If argument feature_names in function eli5.show_weights() is pandas.core.indexes.base.Index raises an TypeError: Unexpected feature_names type.
To reproduce
import eli5
from eli5.sklearn import PermutationImportance
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_boston
data = load_boston()
X, y, feats = data['data'], data['target'], data['feature_names']
X = pd.DataFrame(X, columns=feats)
# Split in train-test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
# Fit model
reg = RandomForestRegressor()
reg.fit(X_train, y_train)
# Run permutation importance
perm = PermutationImportance(reg, random_state=1).fit(X_test, y_test)
# Show weights with pandas.Index
eli5.show_weights(perm, top=None, feature_names=X_test.columns)
>>> TypeError: Unexpected feature_names type
Discussion
Reading the functionality of the FeatureNames class, noticed that some functionalities that feature_names param should satisfy are
If argument
feature_names
in functioneli5.show_weights()
ispandas.core.indexes.base.Index
raises anTypeError: Unexpected feature_names type
.To reproduce
Discussion
Reading the functionality of the FeatureNames class, noticed that some functionalities that
feature_names
param should satisfy areso my question if it is possible to add support for
pandas.core.indexes.base.Index
as argument in show_weights function.