เลือกเกณฑ์ตัดสินและเมตริก
ปรับให้เหมาะกับคลาสที่คุณให้ความสำคัญ
เลือกเกณฑ์ตัดสินและเมตริก เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
The Hidden Threshold
Classifiers output a probability, then a threshold turns it into a label. The default 0.5 is rarely best for rare classes.
Move the Line
Lowering the threshold flags more items as the rare class, catching more true cases at the cost of extra false alarms.
Get Probabilities First
To tune a cutoff you need scores, not just labels. Ask the model for the predicted probability of the positive class.
proba = clf.predict_proba(X_test)[:, 1]Precision or Recall?
Decide what hurts more. Missing rare cases means optimize recall; too many false alarms means favor precision.
F1 Balances Both
When you cannot pick a side, the F1 score blends precision and recall into one number worth maximizing.
The PR Curve
For skewed data the precision-recall curve tells the real story far better than an ROC curve does.
Sweep the Cutoffs
Try many cutoffs and watch how the trade-off shifts. The PR curve shows every precision-recall pair at once.
from sklearn.metrics import precision_recall_curve
p, r, t = precision_recall_curve(y, proba)Apply Your Chosen Cutoff
Once you pick a value, compare each probability to it. Above the line becomes the positive class, below becomes negative.
preds = (proba >= 0.3).astype(int)Beware ROC AUC
ROC AUC can look great on heavy imbalance even when precision is poor, so do not trust it alone here.
Tune on Validation Data
Choose your threshold on a held-out validation set, never on the test set, or your reported numbers will lie.
Metric Mirrors the Goal
The right metric reflects real-world cost. Let the business goal pick precision, recall, or F1, then tune to it. 🎯
Quick Check
Test your grip on thresholds.
Recap
Tune the threshold on validation data, prefer precision, recall, or F1 over accuracy, and trust the PR curve on skew. ✅
คำถามที่พบบ่อย
บทเรียน “เลือกเกณฑ์ตัดสินและเมตริก” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “เลือกเกณฑ์ตัดสินและเมตริก” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “เลือกเกณฑ์ตัดสินและเมตริก”
ปรับให้เหมาะกับคลาสที่คุณให้ความสำคัญ คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “เลือกเกณฑ์ตัดสินและเมตริก” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม
ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เหตุใดคลาสที่พบได้น้อยจึงถูกละเลย
- การสุ่มตัวอย่างใหม่และน้ำหนักคลาส
- เลือกเกณฑ์ตัดสินและเมตริก
- ไปป์ไลน์ข้อมูลไม่สมดุลตั้งแต่ต้นจนจบ