Closed mattharrison closed 2 weeks ago
Posting my workaround for when I search for this in the future others.
import seaborn as sns
makes = ['Ford', 'Toyota', 'Honda', 'Tesla']
(pd.DataFrame(vals.values, columns=X_reg.columns)
.rename(columns=lambda col: f'{col}_shap')
.assign(base_value=vals.base_values, **X_reg)
.pipe(lambda df_:
sns.catplot(x='make', y='make_shap', data=df_, alpha=.5,
hue='year', palette='RdBu',
order=makes))
)
This should be solved by #3706.
Resolved by #3706
Issue Description
I can find examples of scatter plots that show categoricals yet they are label encoded and use the
display_features
ofshap.dependence_plot
to simulate categories.When I create models with categories (with XGBoost or CatBoost), I use 'category' types for the columns.
This fails if I try to create a scatter plot and view the impact of the category.
Minimal Reproducible Example
Traceback
Expected Behavior
I would love to see a scatterplot like the
dependence_plot
examples on this page: https://shap.readthedocs.io/en/latest/example_notebooks/tabular_examples/tree_based_models/Census%20income%20classification%20with%20XGBoost.htmlBug report checklist
Installed Versions
0.46.0