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

Connected

Exercise

SHAP for explaining income levels

Practice using SHAP to analyze and visualize how each feature influences a trained model's predictions on a single sample from the income dataset, using a waterfall plot for deeper insight into feature contributions.

A trained KNN model is loaded for you. The dataset containing features is loaded in X.

Instructions 1/2

undefined XP
    1
    2
  • Create a kernel explainer for the model using a kmeans representation of the dataset X with 10 centroids.
  • Generate shap_values for the first instance in X.