Giter VIP home page Giter VIP logo

sage's Introduction

SAGE

SAGE (Shapley Additive Global importancE) is a game theoretic approach for understanding black-box machine learning models. It summarizes the importance of each feature based on the predictive power it contributes, and accounts for complex feature interactions by using the Shapley value from cooperative game theory.

SAGE is described in detail in this paper, but if you're new to using Shapley values, you might prefer starting with this blog post.

Usage

SAGE is model-agnostic, so you can use it with any kind of machine learning model. All you need to do is wrap the model in a function to make it callable, set up a data imputer, and run the sampling algorithm:

import sage

# Get data
x, y = ...

# Get model
model = ...

# Set up imputer for representing data distribution
imputer = sage.utils.MarginalImputer(x, samples=512)

# Set up sampling object
sampler = sage.PermutationSampler(
    model,
    imputer,
    'cross entropy')

# Calculate SAGE values
sage_values = sampler(
    (x, y),
    batch_size=256,
    n_permutations=8096,
    bar=True)

See credit.ipynb for an example using gradient boosting machines (GBM), and bike.ipynb for an example using a PyTorch multi-layer perceptron (MLP).

Install

There are a couple ways to use the code. The easiest way is installing sage-importance with pip:

pip install sage-importance

Alternatively, you can clone the repository and install the package using the local setup.py file:

pip install .

Authors

References

Ian Covert, Scott Lundberg, Su-In Lee. "Understanding Global Feature Contributions Through Additive Importance Measures." arXiv preprint arXiv:2004.00668, 2020.

sage's People

Contributors

iancovert avatar jjanizek avatar

Stargazers

王硕 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.