-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviourIndicates an unexpected problem or unintended behaviourregressionRegression bugs - worked once, not anymoreRegression bugs - worked once, not anymorevisualizationRelating to plottingRelating to plotting
Milestone
Description
Issue Description
Following the NHANES I Survival Model notebook with shap>=0.47.0 produces a summary plot with only one feature (shown below), instead of the 7x7 matrix shown here.
This might be related to several of the comments on #804, but not to the original issue which is unrelated (this isn't caused by max_display).
Minimal Reproducible Example
# Adapted from https://shap.readthedocs.io/en/latest/example_notebooks/tabular_examples/tree_based_models/NHANES%20I%20Survival%20Model.html
from sklearn.model_selection import train_test_split
import shap
import xgboost
X, y = shap.datasets.nhanesi()
# human readable feature values
X_display, y_display = shap.datasets.nhanesi(display=True)
xgb_full = xgboost.DMatrix(X, label=y)
# create a train/test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=7)
xgb_train = xgboost.DMatrix(X_train, label=y_train)
xgb_test = xgboost.DMatrix(X_test, label=y_test)
# train final model on the full data set
params = {"eta": 0.002, "max_depth": 3, "objective": "survival:cox", "subsample": 0.5}
model = xgboost.train(params, xgb_full, 5000, evals=[(xgb_full, "test")], verbose_eval=1000)
number_patients = 300
shap_interaction_values = shap.TreeExplainer(model).shap_interaction_values(X.iloc[:number_patients, :])
shap.summary_plot(shap_interaction_values, X.iloc[:number_patients, :])Traceback
Expected Behavior
The code should generate the figure below:
Bug report checklist
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest release of shap.
- I have confirmed this bug exists on the master branch of shap.
- I'd be interested in making a PR to fix this bug
Installed Versions
I've confirmed the bug is present in:
0.47.00.47.2master
It is not present in 0.46.0.
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviourIndicates an unexpected problem or unintended behaviourregressionRegression bugs - worked once, not anymoreRegression bugs - worked once, not anymorevisualizationRelating to plottingRelating to plotting