Git Product home page Git Product logo

Comments (3)

wishforgood avatar wishforgood commented on May 18, 2024

Oh maybe I should ask it in the git of shap

from shap-hypetune.

wishforgood avatar wishforgood commented on May 18, 2024

When I use the model.estimator_ to calculate SHAP values, I found that some features corresponds to NaN values, maybe because I used the min_features_to_select option? How can I get the SHAP values used to select the features?

from shap-hypetune.

cerlymarco avatar cerlymarco commented on May 18, 2024

Hi,
in shap-hypetune, shap values are computed using shap.TreeExplainer with feature_perturbation="tree_path_dependent". shap importances are aggregated featurewise using this aggregation: np.abs(shap_values).mean(0). No method is available in shap-hypetune to extract/plot shap importances (since you can directly use the shap library).
To get the shap importances of the selected features, compute the shape values on your data (train or evaluation set using only the selected features) and aggregate them with the calculation np.abs(shap_values).mean(0)

explainer = TreeExplainer(
model, feature_perturbation="tree_path_dependent")
coefs = explainer.shap_values(X)
if isinstance(coefs, list):
coefs = list(map(lambda x: np.abs(x).mean(0), coefs))
coefs = np.sum(coefs, axis=0)
else:
coefs = np.abs(coefs).mean(0)

if u support the project, don't forget to leave a star ;-)

from shap-hypetune.

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.