Skip to main content

Shapash is a Python library which aims to make machine learning interpretable and understandable by everyone.

Project description

tests pypi downloads pyversion license doc

🎉 We just released Shapash 1.3.1 that includes the generation of a standalone HTML report that constitutes a basis of an audit document. See an example here that was generated using this tutorial. 🎉

🔍 Overview

Shapash is a Python library which aims to make machine learning interpretable and understandable by everyone. It provides several types of visualization that display explicit labels that everyone can understand.

Data Scientists can understand their models easily and share their results. End users can understand the decision proposed by a model using a summary of the most influential criteria.

Shapash also contributes to data science auditing by displaying usefull information about any model and data in a unique report.

🔥 Features

  • Display clear and understandable results: plots and outputs use explicit labels for each feature and its values

  • Allow Data Scientists to quickly understand their models by using a webapp to easily navigate between global and local explainability, and understand how the different features contribute: Live Demo Shapash-Monitor

  • Summarize and export the local explanation

Shapash proposes a short and clear local explanation. It allows each user, whatever their Data backround, to understand a local prediction of a supervised model thanks to a summarized and explicit explanation

  • Easily share and discuss results with non-Data users

  • Deploy interpretability part of your project: From model training to deployment (API or Batch Mode)

  • Contribute to the auditability of your model by generating a standalone HTML report of your projects. Report Example

We hope that this report will bring a valuable support to auditing models and data related to a better AI governance. Data Scientists can now deliver to anyone who is interested in their project a document that freezes different aspects of their work as a basis of an audit report. This document can be easily shared across teams (internal audit, DPO, risk, compliance...).

⚙️ How Shapash works

Shapash is an overlay package for libraries dedicated to the interpretability of models. It uses Shap or Lime backend to compute contributions. Shapash builds on the different steps necessary to build a machine learning model to make the results understandable

🛠 Installation

Shapash is intended to work with Python 3.6 or above. Installation can be done with pip:

pip install shapash

🕐 Quickstart

The 4 steps to display results:

  • Step 1: Declare SmartExplainer Object

    You can declare features dict here to specify the labels to display

from shapash.explainer.smart_explainer import SmartExplainer
xpl = SmartExplainer(features_dict=house_dict) # optional parameter
  • Step 2: Compile Model, Dataset, Encoders, ...

    There are 2 mandatory parameters in compile method: Model and Dataset

    preprocessing=encoder, # Optional: compile step can use inverse_transform method
    y_pred=y_pred, # Optional
    postprocessing=postprocess # Optional: see tutorial postprocessing
  • Step 3: Display output

    There are several outputs and plots available. for example, you can launch the web app:

app = xpl.run_app()

Live Demo Shapash-Monitor

  • Step 4: Generate the Shapash Report

    This step allows to generate a standalone html report of your project using the different splits of your dataset and also the metrics you used:

    title_story="House prices report",
    title_description="""This document is a data science report of the kaggle house prices tutorial project.
        It was generated using the Shapash library.""",
    metrics=[{‘name’: ‘MSE’, ‘path’: ‘sklearn.metrics.mean_squared_error’}]

Report Example

  • Step 5: From training to deployment : SmartPredictor Object

    Shapash provides a SmartPredictor object to deploy the summary of local explanation for the operational needs. It is an object dedicated to deployment, lighter than SmartExplainer with additional consistency checks. SmartPredictor can be used with an API or in batch mode. It provides predictions, detailed or summarized local explainability using appropriate wording.

predictor = xpl.to_smartpredictor()

See the tutorial part to know how to use the SmartPredictor object

📖 Tutorials

This github repository offers a lot of tutorials to allow you to start more concretely in the use of Shapash.

More Precise Overview

More details about charts and plots

The different ways to use Encoders and Dictionaries

Better displaying data with postprocessing

How to use shapash with Shap or Lime compute

Generate the Shapash Report

Deploy local explainability in production

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for shapash, version 1.3.1
Filename, size File type Python version Upload date Hashes
Filename, size shapash-1.3.1-py2.py3-none-any.whl (863.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size shapash-1.3.1.tar.gz (713.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page