การอธิบายผลการจำแนกภาพอาหาร
คุณมี model สำหรับจำแนกประเภทอาหาร และต้องใช้ LIME เพื่อระบุบริเวณที่โมเดลให้ความสำคัญมากที่สุดในการพยากรณ์ภาพ image ด้านล่างนี้
model ที่ใช้พยากรณ์, ฟังก์ชัน model_predict และตัวอย่าง image ที่แสดงด้านล่างถูกโหลดไว้ให้แล้ว

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Explainable AI ด้วย Python
คำแนะนำการฝึกหัด
- สร้าง LIME image explainer ชื่อ
explainer - สร้าง
explanationสำหรับผลการพยากรณ์ของmodelบนimageที่กำหนด - ดึงพื้นที่ที่น่าสนใจจาก
imageโดยอิงจากคำอธิบายของmodel
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
from lime import lime_image
np.random.seed(10)
# Create a LIME explainer
explainer = lime_image.____()
# 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()