MulaiMulai sekarang secara gratis

Interpreting classifiers locally

Now you have a KNN classifier model that predicts the presence of heart disease based on features like age, sex, chest pain type, and blood pressure. Your task is to assess how each feature affects the prediction for a given sample.

The KNN model and the necessary packages are pre-loaded for you.

Latihan ini adalah bagian dari kursus

Explainable AI in Python

Lihat Kursus

Petunjuk latihan

  • Create a LIME explainer for the KNN classifier model.
  • Generate an explanation for the model's prediction on the provided sample_data_point.
  • Display the influence of each feature on the prediction.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

from lime.lime_tabular import LimeTabularExplainer

sample_data_point = X.iloc[2, :]

# Create the explainer
explainer = ____

# Generate the explanation
exp = ____

# Display the explanation
exp.____
plt.show()
Edit dan Jalankan Kode