Giter VIP home page Giter VIP logo

Comments (3)

connortann avatar connortann commented on June 25, 2024

Thanks for the bug report!

On the master branch of shap, I can reproduce the issue above with xgboost == 1.7.6 but not with xgboost == 2.0.0.

EDIT: It looks like a difference in the loaded tree_limit:

if tree_limit is None:
tree_limit = -1 if self.model.tree_limit is None else self.model.tree_limit

This is then passed to iteration_range, which replaces the deprecated xgboost parameter ntree_limit as of #2987 :

if tree_limit == -1:
tree_limit = 0
try:
phi = self.model.original_model.predict(
X, iteration_range=(0, tree_limit), pred_contribs=True,
approx_contribs=approximate, validate_features=False
)

  • with XGBoost 1.7.6, self.model.tree_limit is 100. The original model is called with interation_range=(0, 100).
  • with XGBoost 2.0.0, self.model.tree_limit is None. The original model is called with iteration_range=(0, 0).

The RFRegressor fails with an iteration_range that is higher than 1, presumably because the trees are in parallel. So, I think iteration_range is not quite a drop-in replacement for ntree_limit. Perhaps the interation_range should be something like tree_limit / num_parallel_trees?

On a side note, it doesn't look like there are any tests for XGBRFRegressor or XGBRFClassifier at the moment, so it would be good to explore if shap can officially support them. @trivialfis , do you by any chance know about this history of XGBoost & shap, if there is any particular reason why the XGB RF models are seemingly not already supported / tested by shap?

from shap.

connortann avatar connortann commented on June 25, 2024

This may be solved by #3462 , which will improve the XGBoost model loading significantly. As a temporary workaround for now, you could try updating to XGBoost 2+ if possible.

from shap.

connortann avatar connortann commented on June 25, 2024

This should be solved by #3462, and will be released in 0.45.0.

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.