oegedijk / explainerdashboard

Quickly build Explainable AI dashboards that show the inner workings of so-called "blackbox" machine learning models.

Home Page:http://explainerdashboard.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Version `0.4.6` seems to have introduced a bug - cannot access `explainer.X_merged` when `cats` not defined

maxschulz-COL opened this issue · comments

Hey - discovered the following after upgrading to 0.4.6:

from sklearn.ensemble import RandomForestClassifier
from explainerdashboard import ClassifierExplainer
from explainerdashboard.datasets import titanic_survive, titanic_names

X_train, y_train, X_test, y_test = titanic_survive()
train_names, test_names = titanic_names()
model = RandomForestClassifier(n_estimators=50, max_depth=5, random_state=1)
model.fit(X_train, y_train)

explainer = ClassifierExplainer(model, X_test, y_test,
                                # cats=['Deck', 'Embarked',
                                #     {'Gender': ['Sex_male', 'Sex_female', 'Sex_nan']}],
                                # cats_notencoded={'Embarked': 'Stowaway'}, # defaults to 'NOT_ENCODED'
                                # descriptions=feature_descriptions, # adds a table and hover labels to dashboard
                                labels=['Not survived', 'Survived'], # defaults to ['0', '1', etc]
                                idxs = test_names, # defaults to X.index
                                index_name = "Passenger", # defaults to X.index.name
                                target = "Survival", # defaults to y.name
                                )

The above code fails for 0.4.6, but not 0.4.5 - get

ValueError: No objects to concatenate

from

409             else:
    410                 cat_pieces.append(pd.DataFrame({col_name: X[col_name].values}))
--> 412 X_cats = pd.concat(cat_pieces, axis=1)
    414 if cols:
    415     X_cats = X_cats[cols]

Any help would be appreciated :) Thanks 🙏 !

ah, thanks, apparently fixed one thing, broke another thing. Will investigate!

Awesome thanks 🙏