Git Product home page Git Product logo

Comments (3)

slundberg avatar slundberg commented on May 22, 2024 5

Good questions!

  1. All the background examples are evaluated for each sample. In the case you describe there are n * k evaluations of the predictor (passed as a batch to the provider predictor function). I should also note that if k >= 2^d then the entire space is evaluated directly (rather than random sampling subsets from the kernel distribution) and this leads to an exact computation.

  2. Very close except for step 2. As mentioned above, in step 2 we produce n copies with each copy using a different x_i from the background dataset. The expected value of the prediction is taken over these n copies.

  3. The paper presents two approximations to conditional expectations that make them easier to compute. The first is feature independence, which allows us to integrate out each feature independent of the others, and the second is model linearity (as an approximation), which allows us to only provide a single reference value for the background. Tree SHAP does not make either of these assumptions (it just assumes the tree has captured any feature dependence), but Kernel SHAP as implemented here always assumes feature independence, and may assume linearity depending on how you use it. If you just pass one reference value for the background then you are assuming linearity, if you pass multiple samples then it will integrate over them to provide a better approximation.

I should make this clearer in the docs, but I recommend using either a single background data point, a small random subset of the true background, or for the best performance a set of k-medians (weighted by how many training points they each represent) designed to represent the background succinctly. Passing a large background dataset wastes lots of effort. Perhaps I'll add a warning about that to the code.

from shap.

Jianbo-Lab avatar Jianbo-Lab commented on May 22, 2024

I see. It is much clearer now. Thanks!

from shap.

slundberg avatar slundberg commented on May 22, 2024

I should also mention that the choice to use a single background reference or multiple samples depends on the type of input data. For images, integrating over a few instances is unlikely to be any better an approximation that just using a single reference. But for structured data using 20 weighted k-medians or a small random subsample might help.

from shap.

Related Issues (20)

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.