GithubHelp home page GithubHelp logo

Comments (8)

AvantiShri avatar AvantiShri commented on June 3, 2024 2

Thanks @orionr! One thing to note about how I implemented support for this feature in my fork of the shap repository (which is linked to in the notebook above) is that I allow the user to optionally provide a custom function that takes as input the (multipliers, original input, references) and returns the final scores - I think the equivalent in Captum would be allowing a user to provide a custom function that varies the logic in this line:

(input - baseline) * gradient

The main reason to provide some flexibility here (in terms of how the user might like to combine the multipliers with the inputs/references to give the final contribution scores) is that for one-hot encoded sequences, sometimes getting the contributions is not as simple as doing multiplier*difference-from-baseline. Specifically, imagine you have a one-hot encoded sequence where only one character at each position can be a 1 (as is often done in character encodings in NLP, or sequence encodings in genomics). Say there are four characters, and the encoding at some position in the input sequence is [1,0,0,0] while the reference at that position is [0,1,0,0]. DeepLIFT will assign a contribution to the first character having a difference-from-reference of +1 and the second character having a difference-from-reference of -1. However, because of the one-hot encoding constraint that only one character at each position can have a 1, the difference-from-reference of -1 in the second character is in some sense "due to" the difference-from-reference of +1 in the first character. Thus, for ease of visualization, we add the contribution of the second character (the one that is absent from the input) to the contribution of the character that is actually present in the input, and then only visualize the total contribution on the character that is actually present in the input. If we did not do this, then at visualization time we would we get scores on more than one character at each position, which is extremely confusing given the one-hot encoding constraint!

Just something I thought I would highlight since @NarineK referenced this feature and I wasn't sure if you had decided to start working on it yet. Please let me know if you would like me to clarify more, or if anything I have said does not make sense!

Thank you again for the hard work!

Avanti

from captum.

NarineK avatar NarineK commented on June 3, 2024 2

Hi @AvantiShri, sure, that makes sense to me. We can take an additional custom function as an argument and in case it is not provided we can use our default logic. This shouldn't be a big change. I'm currently adding layer/neuron based support and will add this functionality as next.

from captum.

NarineK avatar NarineK commented on June 3, 2024 1

Hi Avanti, Thank you very much for the feedback! Happy to hear that you liked it.
I think that it shouldn't be an issue to return the multipliers.

Thank you very much for jupyter notebook. I'll check it out :)

from captum.

orionr avatar orionr commented on June 3, 2024

Not going to close this, since we can consider it as a feature request that we aren't working on yet. Thanks, @AvantiShri!

from captum.

AvantiShri avatar AvantiShri commented on June 3, 2024

Awesome, thank you!

from captum.

AidenSb avatar AidenSb commented on June 3, 2024

Hi @AvantiShri
Thanks for suggesting this. I have a question regarding the custom function and would really appreciate it if you could give some advice.
so I have used captum deeplift to calculate my attributions and followed the best recipe ( I basically run captum deep lift on my sequence with 10 different dinucleotides shuffled sequences and averaged over them).
Now I'm trying to get the hypothetical contributions and planning to use the same approach but this time input a custom function. I couldn't understand the example on the deepShap repo, and inputting it to the captum function is not working, would you be able to kindly suggest a simple formula to use the input, base and multiplier in a custom function? or if you already have a function that works for this matter, I would really appreciate it if you could share it.

from captum.

AvantiShri avatar AvantiShri commented on June 3, 2024

from captum.

AidenSb avatar AidenSb commented on June 3, 2024

@AvantiShri Thanks Avanti, I hope all is well now. The slides are really helpful I appreciate it.

from captum.

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.