Error when using: db = ExplainerDashboard.from_config("dashboard.yaml").flask_server()
jaimeggb opened this issue · 2 comments
jaimeggb commented
The last part of the error is:
TypeError: _rebuild() got an unexpected keyword argument 'impl_kind'
The full error is:
C:\virtual_environments\venv_ipo_2\lib\site-packages\xgboost\core.py:160: UserWarning: [09:05:33] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0b3782d1791676daf-1\xgboost\xgboost-ci-windows\src\common/error_msg.h:80: If you are loading a serialized model (like pickle in Python, RDS in R) or
configuration generated by an older version of XGBoost, please export the model by calling
`Booster.save_model` from that version first, then load it back in current version. See:
https://xgboost.readthedocs.io/en/stable/tutorials/saving_model.html
for more details about differences between saving model and serializing.
Traceback (most recent call last):
File "C:\web_app_explainer\app.py", line 4, in <module>
db = ExplainerDashboard.from_config("dashboard.yaml").flask_server()
File "C:\virtual_environments\venv_ipo_2\lib\site-packages\explainerdashboard\dashboards.py", line 908, in from_config
explainer = BaseExplainer.from_file(config["dashboard"]["explainerfile"])
File "C:\virtual_environments\venv_ipo_2\lib\site-packages\explainerdashboard\explainers.py", line 428, in from_file
return joblib.load(filepath)
File "C:\virtual_environments\venv_ipo_2\lib\site-packages\joblib\numpy_pickle.py", line 658, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "C:\virtual_environments\venv_ipo_2\lib\site-packages\joblib\numpy_pickle.py", line 577, in _unpickle
obj = unpickler.load()
File "C:\AppData\Local\Programs\Python\Python39\lib\pickle.py", line 1212, in load
dispatch[key[0]](self)
File "C:\AppData\Local\Programs\Python\Python39\lib\pickle.py", line 1589, in load_reduce
stack[-1] = func(*args)
File "C:\virtual_environments\venv_ipo_2\lib\site-packages\numba\core\serialize.py", line 152, in custom_rebuild
return cls._rebuild(**states)
TypeError: _rebuild() got an unexpected keyword argument 'impl_kind'
The full python code I'm using in app.py
is:
from explainerdashboard import ExplainerDashboard
# Load the dashboard configuration
db = ExplainerDashboard.from_config("dashboard.yaml").flask_server()
# Create a flask app instance to serve the dashboard
app = db.flask_server()
if __name__ == "__main__":
app.run(debug=True)
The files of relevance in the web_app_explainer
folder are:
- app.py
- explainer.joblib
- dashboard.yaml
oegedijk commented
Looks like maybe you installed a new version of xgboost than the version under which you stored the explainer? And the new version cannot load the old format? (I think xgboost recently released 2.0 right?)
jaimeggb commented
Yes that was one of the problems. I had to downgrade to xgboost==1.7.2. In the end the dependencies used that worked after much trial and error were:
cloudpickle
explainerdashboard==0.4.7
xgboost==1.7.2
mlflow
numba==0.58.1
pandas==1.4.2
And the code that worked was:
import cloudpickle
from explainerdashboard import ExplainerDashboard
from flask import Flask
# Load the explainer object with cloudpickle
with open("explainer.joblib", "rb") as f:
explainer = cloudpickle.load(f)
# Create the ExplainerDashboard instance directly instead of using dashboard.yaml configuration file
dashboard = ExplainerDashboard(explainer,
title="Title",
description="Description text.",
simple=False,
# add other parameters as needed
)
# Create a Flask app instance to serve the dashboard
app = dashboard.flask_server()