.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/explainerdashboard/plot_main_01.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_main_01.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 .. GENERATED FROM PYTHON SOURCE LINES 12-35 .. rst-class:: sphx-glr-script-out Out: .. code-block:: none "\n# Libraries\nfrom sklearn.ensemble import RandomForestClassifier\nfrom explainerdashboard import ClassifierExplainer\nfrom explainerdashboard import ExplainerDashboard\nfrom explainerdashboard.datasets import titanic_survive\nfrom explainerdashboard.datasets import feature_descriptions\n\n# Get data\nX_train, y_train, X_test, y_test = titanic_survive()\n\n# Create and fit model\nmodel = RandomForestClassifier(n_estimators=50, max_depth=10) .fit(X_train, y_train)\n\n# Configure explainer\nexplainer = ClassifierExplainer(model, X_test, y_test,\n cats=['Sex', 'Deck', 'Embarked'],\n descriptions=feature_descriptions,\n labels=['Not survived', 'Survived'])\n\n# Run\n#ExplainerDashboard(explainer).run()\n" | .. code-block:: default :lineno-start: 12 """ # Libraries from sklearn.ensemble import RandomForestClassifier from explainerdashboard import ClassifierExplainer from explainerdashboard import ExplainerDashboard from explainerdashboard.datasets import titanic_survive 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 #ExplainerDashboard(explainer).run() """ .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.004 seconds) .. _sphx_glr_download__examples_explainerdashboard_plot_main_01.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_main_01.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main_01.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_