開始使用免費開始

用 LIME 評估 faithfulness

你已獲得收入資料集中範例 X_instance 的 LIME 解釋。由於性別是最重要的預測因子,你需要變更它的數值,並計算 faithfulness,以判斷該解釋與模型在此個別樣本上的行為是否一致。

本練習屬於課程

Python 的 Explainable AI

檢視課程

練習說明

  • X_instance 中的性別值改為 0。
  • 產生 new_prediction 的機率。
  • 估計 LIME 解釋的 faithfulness

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

original_prediction = model.predict_proba(X_instance)[0, 1]
print(f"Original prediction: {original_prediction}")

# Change the gender value to 0 
____

# Generate the new prediction
new_prediction = ____
print(f"Prediction after perturbing 'gender': {new_prediction}")

# Estimate faithfulness
faithfulness_score = ____
print(f"Local Faithfulness Score: {faithfulness_score}")
編輯並執行程式碼