BaşlayınÜcretsiz Başlayın

Explaining sentiment analysis predictions

You are provided with a model that classifies product reviews as expressing positive or negative sentiment. Your task is to use LIME to identify which words in a given text_instance most influence the model's predictions.

The model_predict function for processing input texts is pre-loaded for you.

Bu egzersiz

Explainable AI in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a LIME text explainer named explainer.
  • Generate an explanation for the model's prediction on the given text_instance featuring the top five features.
  • Display the top contributing words and their weights that influence the model's decision.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from lime.lime_text import LimeTextExplainer

text_instance = "Amazing battery life and the camera quality is perfect! I highly recommend this smartphone."

# Create a LIME text explainer
explainer = ____

# Generate the explanation
exp = ____

# Display the explanation
____
plt.show()
Kodu Düzenle ve Çalıştır