.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples\explainerdashboard\plot_main01.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_explainerdashboard_plot_main01.py: 01. Explainer Dash ==================== This example runs an app which an interactive user interface to explore the importance of the features using SHAP values. .. note:: https://github.com/oegedijk/explainerdashboard .. note:: See https://titanicexplainer.herokuapp.com/ .. note:: Requires plotly<6 .. GENERATED FROM PYTHON SOURCE LINES 16-75 .. rst-class:: sphx-glr-script-out Out: .. code-block:: none The version of 'plotly' is: 6.3.1 | .. code-block:: default :lineno-start: 16 # Libraries import sys try: __file__ TERMINAL = True except: TERMINAL = False def check_version(name): """""" if sys.version_info >= (3, 8): # Since python 3.8 from importlib.metadata import version, PackageNotFoundError else: # For older Python versions, you need to install the backport from importlib_metadata import version, PackageNotFoundError try: pkg_version = version(name) print(f"The version of '{name}' is: {pkg_version}") return pkg_version except PackageNotFoundError: print("One of the packages is not installed.") return None if __name__ == '__main__': if check_version('plotly') < '6': # Libraries from sklearn.ensemble import RandomForestClassifier from explainerdashboard import ClassifierExplainer from explainerdashboard import ExplainerDashboard from explainerdashboard.datasets import titanic_survive from explainerdashboard.datasets import titanic_names from explainerdashboard.datasets import feature_descriptions # Get data X_train, y_train, X_test, y_test = titanic_survive() # Create and fit model model = RandomForestClassifier(n_estimators=50, max_depth=10) \ .fit(X_train, y_train) # Configure explainer explainer = ClassifierExplainer(model, X_test, y_test, cats=['Sex', 'Deck', 'Embarked'], descriptions=feature_descriptions, labels=['Not survived', 'Survived']) # Run if TERMINAL: ExplainerDashboard(explainer).flask_server() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.005 seconds) .. _sphx_glr_download__examples_explainerdashboard_plot_main01.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_main01.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main01.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_