Get startedGet started for free

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.

This exercise is part of the course

Explainable AI in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

import shap

# Create the SHAP explainer
explainer = ____

# Compute SHAP values for the first instance in X
shap_values = ____

print(shap_values)
Edit and Run Code