explainerdashboard CLI

The library comes with a explainerdashboard command line tool (CLI) that you can use to build and run explainerdashboards from your terminal. This makes it easy to start a dashboard without having to run python code or start a notebook first. You can also use it to build explainer objects as part of a CI/CD flow.

Run dashboard from stored explainer

In order to run a dashboard from a stored explainer from the commandline, we first need to store an explainer to disk. You can do this with:

explainer = ClassifierExplainer(model, X, y)

And then you can run the default dashboard and launch a browser tab from the command line by running:

$ explainerdashboard run explainer.joblib

The CLI uses the waitress web server by default to run your dashboard. To run on a specific port, not launch a browser or show help:

$ explainerdashboard run explainer.joblib --port 8051
$ explainerdashboard run explainer.joblib --no-browser
$ explainerdashboard run --help

Run custom dashboard from dashboard.yaml

If you’d like to launch a custom dashboard with custom tabs and parameters, you can do so by storing the configuration to .yaml:

db = ExplainerDashboard(explainer, [ShapDependenceTab, "importances"],
        port=9000, title="Custom Dashboard", header_hide_title=True)
db.to_yaml("dashboard.yaml", explainerfile="explainer.joblib")

You can edit dashboard.yaml directly to make further configuration changes if you wish. Start the dashboard from the commandline with:

$ explainerdashboard run dashboard.yaml

Building explainers from explainer.yaml

You can build also explainers from the commandline by storing the model (e.g. model.pkl) and datafile (e.g. data.csv), indicating which column is y (e.g. 'Survival'), and which is the index (e.g. 'Name'), along with the other parameters of the explainer.

You can get this configuration by storing the configuration as before:

explainer = ClassifierExplainer(model, X, y,
                labels=['Not survived', 'Survived'])
pickle.dump(model, open("model.pkl", "wb))


You can then build the explainer.joblib file by running:

$ explainerdashboard build explainer.yaml

This will load the model and dataset, construct an explainer, construct the custom dashboard, calculate all properties needed for that specific dashboard, and store the explainer to disk. This can be useful when you for example would like to populate the dashboard with a new set of data: you can simply update data.csv and run explainerdashboard build. To start the dashboard you can then run:

$ explainerdashboard run dashboard.yaml

To build the explainer for a specific dashboard (other than the one specified in dashboard_yaml, pass it as a second argument:

$ explainerdashboard build explainer.yaml dashboard.yaml


If you use the default naming scheme of explainer.joblib, dashboard.yaml and explainer.yaml, you can omit these arguments and simply run e.g.:

$ explainerdashboard build
$ explainerdashboard run

dump, from_file, to_yaml



Dump the current Explainer to file. Depending on the suffix of the filepath will either dump with pickle (‘.pkl’), dill (‘.dill’) or joblib (‘joblib’).

If no suffix given, will dump with joblib and add ‘.joblib’


filepath (str, Path) – filepath where to save the Explainer.


classmethod BaseExplainer.from_file(filepath)

Load an Explainer from file. Depending on the suffix of the filepath will either load with pickle (‘.pkl’), dill (‘.dill’) or joblib (‘joblib’).

If no suffix given, will try with joblib.

  • {str (filepath) –

  • Explainer (Path} the location of the stored) –


Explainer object


BaseExplainer.to_yaml(filepath=None, return_dict=False, modelfile='model.pkl', datafile='data.csv', index_col=None, target_col=None, explainerfile='explainer.joblib', dashboard_yaml='dashboard.yaml')

Returns a yaml configuration for the current Explainer that can be used by the explainerdashboard CLI. Recommended filename is explainer.yaml.

  • filepath ({str, Path}, optional) – Filepath to dump yaml. If None returns the yaml as a string. Defaults to None.

  • return_dict (bool, optional) – instead of yaml return dict with config.

  • modelfile (str, optional) – filename of model dump. Defaults to model.pkl

  • datafile (str, optional) – filename of datafile. Defaults to data.csv.

  • index_col (str, optional) – column to be used for idxs. Defaults to self.idxs.name.

  • target_col (str, optional) – column to be used for to split X and y from datafile. Defaults to self.target.

  • explainerfile (str, optional) – filename of explainer dump. Defaults to explainer.joblib.

  • dashboard_yaml (str, optional) – filename of the dashboard.yaml configuration file. This will be used to determine which properties to calculate before storing to disk. Defaults to dashboard.yaml.


ExplainerDashboard.to_yaml(filepath=None, return_dict=False, explainerfile='explainer.joblib', dump_explainer=False, explainerfile_absolute_path=None)

Returns a yaml configuration of the current ExplainerDashboard that can be used by the explainerdashboard CLI or to reinstate an identical dashboard from the (dumped) explainer and saved configuration. Recommended filename is dashboard.yaml.

  • filepath ({str, Path}, optional) – Filepath to dump yaml. If None returns the yaml as a string. Defaults to None.

  • return_dict (bool, optional) – instead of yaml return dict with config.

  • explainerfile (str, optional) – filename of explainer dump. Defaults to explainer.joblib. Should en in either .joblib .dill or .pkl

  • dump_explainer (bool, optional) – dump the explainer along with the yaml. You must pass explainerfile parameter for the filename. Defaults to False.

  • explainerfile_absolute_path (str, Path, bool, optional) – absolute path to save explainerfile if not in the same directory as the yaml file. You can also pass True which still saves the explainerfile to the filepath directory, but adds an absolute path to the yaml file.


classmethod ExplainerDashboard.from_config(arg1, arg2=None, **update_params)

Loading a dashboard from a configuration .yaml file. You can either pass both an explainer and a yaml file generated with ExplainerDashboard.to_yaml(“dashboard.yaml”):

db = ExplainerDashboard.from_config(explainer, “dashboard.yaml”)

When you specify an explainerfile in to_yaml with ExplainerDashboard.to_yaml(“dashboard.yaml”, explainerfile=”explainer.joblib”), you can also pass just the .yaml:

db = ExplainerDashboard.from_config(“dashboard.yaml”)

You can also load the explainerfile seperately:

db = ExplainerDashboard.from_config(“explainer.joblib”, “dashboard.yaml”)

  • arg1 (explainer or config) – arg1 should either be a config (yaml or dict), or an explainer (instance or str/Path).

  • arg2 ([type], optional) – If arg1 is an explainer, arg2 should be config.

  • update_params (dict) – You can override parameters in the the yaml config by passing additional kwargs to .from_config()