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

ImportError: cannot import name 'dtreeviz' from 'dtreeviz.trees'

lalitsc12 opened this issue · comments

I am getting this error not sure what is the issue.

ImportError: cannot import name 'dtreeviz' from 'dtreeviz.trees'

i am using the simple example in jupyter notebook

from pycaret.datasets import get_data
data=get_data('juice')
from pycaret.classification import *
s=setup(data,target='Purchase',session_id=123)
lr=create_model('lr')

dashboard(lr,display_format='inline')

this is when i get error:.
Cell In[7], line 1
----> 1 dashboard(lr,display_format='inline')

File ~/anaconda3/envs/Lalit_env/lib/python3.9/site-packages/pycaret/utils/generic.py:965, in check_if_global_is_not_none..decorator..wrapper(*args, **kwargs)
963 if globals_d[name] is None:
964 raise ValueError(message)
--> 965 return func(*args, **kwargs)

File ~/anaconda3/envs/Lalit_env/lib/python3.9/site-packages/pycaret/classification/functional.py:2997, in dashboard(estimator, display_format, dashboard_kwargs, run_kwargs, **kwargs)
2944 @check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
2945 def dashboard(
2946 estimator,
(...)
2950 **kwargs,
2951 ):
2952 """
2953 This function generates the interactive dashboard for a trained model. The
2954 dashboard is implemented using ExplainerDashboard (explainerdashboard.readthedocs.io)
(...)
2995 ExplainerDashboard
2996 """
-> 2997 return _CURRENT_EXPERIMENT.dashboard(
2998 estimator, display_format, dashboard_kwargs, run_kwargs, **kwargs
2999 )

File ~/anaconda3/envs/Lalit_env/lib/python3.9/site-packages/pycaret/classification/oop.py:3419, in ClassificationExperiment.dashboard(self, estimator, display_format, dashboard_kwargs, run_kwargs, **kwargs)
3416 dashboard_kwargs = dashboard_kwargs or {}
3417 run_kwargs = run_kwargs or {}
-> 3419 from explainerdashboard import ClassifierExplainer, ExplainerDashboard
3421 le = get_label_encoder(self.pipeline)
3422 if le:

File ~/anaconda3/envs/Lalit_env/lib/python3.9/site-packages/explainerdashboard/init.py:1
----> 1 from .explainers import ClassifierExplainer, RegressionExplainer
2 from .dashboards import ExplainerDashboard, ExplainerHub, InlineExplainer

File ~/anaconda3/envs/Lalit_env/lib/python3.9/site-packages/explainerdashboard/explainers.py:25
21 from pandas.api.types import is_numeric_dtype, is_string_dtype
23 import shap
---> 25 from dtreeviz.trees import ShadowDecTree, dtreeviz
27 from sklearn.pipeline import Pipeline
28 from sklearn.metrics import roc_auc_score, accuracy_score, f1_score

ImportError: cannot import name 'dtreeviz' from 'dtreeviz.trees

I had the same error while installing the package via conda (https://anaconda.org/conda-forge/explainerdashboard). It seems to be the case that the conda version is not the latest. Either you can downgrade your dtreeviz package or update your explainerdashboard version.
At least for me, it worked after updating the package to the latest version (0.4.3).

So the conda-forge version was behind for a while because the CI could not deal with the numpy<1.25 requirement (that was needed due to numba and the latest numpy not playing nice together). It seems it works again with the latest numpy, so I removed the requirement and now the conda-forge build works as well, so now both PyPI and conda-forge are on 0.4.5 which should be compatible with the latest version of dtreeviz...