การปรับแต่ง Threshold
ในวิดีโอ คุณได้เรียนรู้วิธีที่ NannyML คำนวณค่า threshold และวิธีปรับแต่งให้เหมาะกับโซลูชันของคุณ
ในแบบฝึกหัดนี้ ให้กำหนด custom threshold 2 แบบ ได้แก่ แบบ standard deviation และแบบ constant จากนั้นนำไปใช้กับผลลัพธ์จากอัลกอริทึม CBPE สำหรับชุดข้อมูล US Census
ชุดข้อมูล reference และ analysis ถูกโหลดไว้ล่วงหน้าในตัวแปร reference และ analysis พร้อมกับไลบรารี nannyml
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การติดตามตรวจสอบ Machine Learning ด้วย Python
คำแนะนำการฝึกหัด
- Import
ConstantThresholdและStandardDeviationThresholdจากnannyml.thresholds - เริ่มต้นใช้วิธี standard deviation และกำหนดพารามิเตอร์
std_lower_multiplierและstd_upper_multiplierเป็น2 - เริ่มต้นใช้วิธี constant threshold และกำหนด lower เป็น
0.9และ upper เป็น0.98 - ส่ง constant threshold สำหรับ metric
f1และ standard deviation สำหรับaccuracyไปยังอัลกอริทึม CBPE
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import custom thresholds
from ____.____ import ____, ____
# Initialize custom thresholds
stdt = ____(____=____, ____=____)
ct = ____(____=____, ____=____)
# Initialize the CBPE algorithm
estimator = nannyml.CBPE(
problem_type='classification_binary',
y_pred_proba='predicted_probability',
y_pred='prediction',
y_true='employed',
metrics=['roc_auc', 'accuracy', 'f1'],
thresholds={____: ____, ____: ____})