การอธิบายข้อความและรูปภาพด้วย LIME

Explainable AI ด้วย Python

Fouad Trad

Machine Learning Engineer

โมเดลที่ใช้ข้อความ

  • ประมวลผลและตีความภาษาเขียน
  • ตัวอย่าง: การวิเคราะห์ความรู้สึก
  • โมเดล Black box
  • LimeTextExplainer ใช้อธิบายโมเดลดังกล่าว
    • ค้นหาว่าแต่ละคำส่งผลต่อการทำนายอย่างไร

โมเดลวิเคราะห์ความรู้สึกที่รับรีวิวจากผู้ใช้และทำนายความรู้สึกที่สอดคล้อง ('Positive' หรือ 'Negative')

Explainable AI ด้วย Python

LIME text explainer

from lime.lime_text import LimeTextExplainer

text_instance = "This product has great features but a poor design."
def model_predict(instance): ... return class_probabilities
explainer = LimeTextExplainer()
exp = explainer.explain_instance(
text_instance,
model_predict
)
exp.as_pyplot_figure()

output_sentiment.png

Explainable AI ด้วย Python

โมเดลที่ใช้รูปภาพ

  • ซับซ้อนสูง
  • ตีความข้อมูลภาพ
  • ตัวอย่าง: การจำแนกประเภทอาหาร
  • LimeImageExplainer ใช้อธิบายโมเดลดังกล่าว
    • ค้นหาว่าส่วนใดของภาพส่งผลต่อการทำนาย

โมเดลจำแนกประเภทอาหารที่รับภาพพิซซ่าและทำนายว่าในภาพเป็นอาหารประเภทใด

Explainable AI ด้วย Python

LIME image explainer

from lime.lime_image import LimeImageExplainer

explainer = LimeImageExplainer()
explanation = explainer.explain_instance(
image,
model_predict,
num_samples=50
)
temp, _ = explanation.get_image_and_mask(
explanation.top_labels[0],
hide_rest=True
)

ภาพไอศกรีม

Explainable AI ด้วย Python

LIME image explainer

from lime.lime_image import LimeImageExplainer

explainer = LimeImageExplainer()
explanation = explainer.explain_instance(
  image, 
  model_predict,  
  num_samples=50
)

temp, _ = explanation.get_image_and_mask(
  explanation.top_labels[0], 
  hide_rest=True
)

plt.imshow(temp)

ภาพไอศกรีมที่ส่วนที่ไม่เกี่ยวข้องถูกปิดทับด้วยสีดำ

Explainable AI ด้วย Python

มาฝึกกันเถอะ!

Explainable AI ด้วย Python

Preparing Video For Download...