Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/shapPublic

BUG: Additivity Check Failure for TreeExplainer uint32 Overflow #4002

Open
Labels
bugIndicates an unexpected problem or unintended behaviour
@arhall0

Description

@arhall0

Issue Description

A related but separate issue to#3948; you can end up with additivity check errors if your number of samples * number of features * number of outputs is greater than the maxuint32 value 4,294,967,295.

These are the dimensions ofphihttps://github.com/shap/shap/blob/master/shap/explainers/_tree.py#L589 which is converted to the linear arrayout_contribs used inshap/cext/tree_shap.h.

out_contibs is indexed in multiple places with a highest precision ofuint32 such ashttps://github.com/shap/shap/blob/master/shap/cext/tree_shap.h#L531

This means a not so unreasonable combination of number of samples and features could result in this error.

Minimal Reproducible Example

importnumpyasnpfromsklearn.ensembleimportRandomForestClassifierimportshapseed=0n_rows=2_000rng=np.random.default_rng(seed)X=rng.integers(low=0,high=2,size=(n_rows,1_100_000)).astype(np.float64)y=rng.integers(low=0,high=2,size=n_rows)clf=RandomForestClassifier(random_state=seed)clf.fit(X,y)clf.predict_proba(X)exp=shap.Explainer(clf,algorithm='tree',feature_perturbation='tree_path_dependent')exp(X)

Traceback

shap.utils._exceptions.ExplainerError: Additivity check failedin TreeExplainer! Please ensure the data matrix you passed to the explainer is the same shape that the model was trained on. If your data shape is correctthen please report this on GitHub. Consider retrying with the feature_perturbation='interventional' option. This check failed becausefor one of the samples the sum of the SHAP values was 1.039915,while the model output was 0.180000. If this difference is acceptable you canset check_additivity=False to disable this check.

Expected Behavior

No response

Bug report checklist

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on thelatest release of shap.
  • I have confirmed this bug exists on themaster branch of shap.
  • I'd be interested in making a PR to fix this bug

Installed Versions

0.46.1.dev107

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp