ประเมินความสอดคล้องของคำอธิบาย SHAP
ประเมินความสอดคล้องของคำอธิบายความสำคัญของฟีเจอร์โดยใช้ SHAP values จากชุดข้อมูลย่อยสองชุดที่แตกต่างกันของชุดข้อมูลประกันภัย
ชุดข้อมูลย่อย X1, X2, y1 และ y2 ถูกโหลดไว้ให้แล้ว พร้อมกับ model1 ที่ฝึกบนชุดข้อมูลชุดแรก และ model2 ที่ฝึกบนชุดข้อมูลชุดที่สอง
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Explainable AI ด้วย Python
คำแนะนำการฝึกหัด
- คำนวณ
shap_values1และfeature_importance1สำหรับmodel1 - คำนวณ
shap_values2และfeature_importance2สำหรับmodel2 - คำนวณ
consistencyระหว่างค่าความสำคัญของฟีเจอร์ทั้งสอง
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Calculate SHAP values and feature importance for model1
explainer1 = shap.TreeExplainer(model1)
shap_values1 = ____
feature_importance1 = ____
# Calculate SHAP values and feature importance for model2
explainer2 = shap.TreeExplainer(model2)
shap_values2 = ___
feature_importance2 =____
# Consistency calculation
consistency = ____
print("Consistency between SHAP values:", consistency)