Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Explainable AI in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

import shap

# Create the SHAP explainer
explainer = ____

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

print(shap_values)
Code bewerken en uitvoeren