GithubHelp home page GithubHelp logo

nredell / shapflex Goto Github PK

View Code? Open in Web Editor NEW
70.0 8.0 7.0 2.18 MB

An R package for computing asymmetric Shapley values to assess causality in any trained machine learning model

License: Other

R 100.00%
shapley shapley-value ensemble machine-learning package r feature-importance shapley-values iml interpretable-machine-learning

shapflex's People

Contributors

nredell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shapflex's Issues

Re-work everything

The package should work as intended, but I need to go back through and tighten up the API. I also need to add tests and generally more clarity and flexibility with what can and can't be tuned.

Shap Interaction

Hi, I've tried to extract the pairwise shap interaction returned by the shap.scatter plot. I've noticed that shap_interaction(X_i, X_j) != shap_interaction(X_j, X_i), Thus if we immagine a MxM interaction matrix, it's not symmetric. Is It normal o r I've done something wrong? And if it's ok, why is that?
Thanks in Advance, Lorenzo

Add multi-class/outcome support

At present, the package only works with single-outcome regression models. This isn't stated anywhere and, well, the logo seems to imply otherwise. Fix.

Result from symmetric shap does NOT match with the SHAP package

I dumped the adult_dataset that you mention in ReadMe into a csv and run a RandomForestClassifier with almost same settings and calculate shap values from the SHAP package library in python (as given by the author of SHAP paper). I then compare these results with the symmetric counterpart of your library.

  1. As a result, I can't see the same (even approximately) set of global shapley values.
  2. Also I don't understand for calculating the global shapley value, you find the mean of shapley values for every instance while the SHAP paper suggests doing an mean of absolute of those shapley values.

Pseudo Code:

import numpy as np
import pandas as pd
import shap
from sklearn.ensemble import RandomForestClassifier

df = pd.read_csv('adult_dataset.csv')
# encode categorical variables and get features and labels in X, y
X, y = preprocess(df)
model = RandomForestClassifier(max_depth=6, random_state=0, n_estimators=300)
model.fit(X, y)

shap.initjs()
explainer= shap.TreeExplainer(model, data=X)
shap_values = explainer.shap_values(X)

# Global shapley values
gsv = np.mean(np.abs(shap_values[1]), axis=0)

As a side note, TreeExplainer finds exact shap values but your results don't match with KernelExplainer even.

Thanks in advance.

Clarify and add sampling methods

The sampling method(s) in the package need to be more clearly spelled out. There are a of couple related methods in the literature that I'd like to incorporate. Namely, there should be a clear trade-off that the user can make between sampling instances vs. features. Right now, the stochastic-ness in the algorithm is to sample a random instance and shuffle its features in one go...but there might be benefit to sampling one instance and shuffling its features multiple times. Seems like both approaches would converge in the limit but the whole point of the Monte Carlo approach is that we're nowhere near "the limit". Also, the impact of feature dependence needs to be worked out. I've done some reading here but I'm not confident about what the best approach is.

Question: Sigma Unique

Hello,
thanks a lot for implementing the idea of decomposing the R2 Shapley decomposition in R.
I've tried to understand and implement all steps you mention in your paper.
The main important thing for me is the calculation of the sigma unique (due to feature correlations). However, by applying the formula in the paper I receive values higher than one.
So I was wondering whether I have to replace the real y by the predicted y in the counter of the formula?

package ‘shapFlex’ is not available for this version of R

Hello. I am trying to use your package to assess healthcare attrition on a large scale, However, I am unable to install this package.

install.packages("shapFlex")
Warning in install.packages :
package ‘shapFlex’ is not available for this version of R

What should I do?

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.