Aan de slagGa gratis aan de slag

Explaining food image predictions

You have a model that classifies food, and your task is to use LIME to identify the regions the model mostly focuses on while making its prediction for the image below.

The model responsible for predictions, the model_predict function and the sample image shown below are pre-loaded for you.

Image for fries

Deze oefening maakt deel uit van de cursus

Explainable AI in Python

Cursus bekijken

Oefeninstructies

  • Create a LIME image explainer named explainer.
  • Generate an explanation for the model's prediction on the given image.
  • Extract the areas of interest from the image based on the model's explanation.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

from lime import lime_image
np.random.seed(10)

# Create a LIME explainer
explainer = ____

# Generate the explanation
explanation = explainer.____(____, ____, hide_color=0, num_samples=50)

# Display the explanation
temp, _ = explanation.____(____, ____)
plt.imshow(temp)
plt.title('LIME Explanation')
plt.axis('off')
plt.show()
Code bewerken en uitvoeren