1. Learn
  2. /
  3. Courses
  4. /
  5. Explainable AI in Python

Connected

Exercise

SHAP vs. model-specific approaches

You will compare the explanatory power of SHAP values from a Kernel Explainer with the logistic regression coefficients, both trained on the income dataset. A helper function plot_importances() is called at the end of the script to plot importances on the same plot.

X containing the features and y containing the labels, and the logistic regression model have been pre-loaded for you. matplotlib.pyplot has been imported as plt.

Instructions

100 XP
  • Compute the coefficients of the logistic regression model.
  • Create Kernel Explainer to compute shap_values using the logistic regression model and a k-means summary of 10 samples from X.
  • Compute the mean absolute SHAP values to estimate the impact of each feature.