ความแม่นยำ ความครอบคลุม และ F1
ชั่งน้ำหนักระหว่างความผิดพลาดแต่ละประเภท
ความแม่นยำ ความครอบคลุม และ F1 เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Accuracy Falls Short
When one class is rare, accuracy can look great while the model misses everything that matters. You need sharper metrics like precision and recall. 🎯
Precision Defined
Precision asks: of all the cases I flagged as positive, how many were truly positive? It measures how trustworthy a yes really is.
precision = TP / (TP + FP)When Precision Matters
High precision matters when false alarms are costly, like marking a real email as spam. You want every flag to be correct.
Recall Defined
Recall asks: of all the truly positive cases, how many did I catch? It measures how good the model is at not missing things.
recall = TP / (TP + FN)When Recall Matters
High recall matters when misses are dangerous, like screening for a disease. Catching every real case outweighs a few false alarms.
The Tug of War
Precision and recall usually pull against each other. Flag more cases and you catch more but raise false alarms. It is a trade-off.
Enter the F1 Score
The F1 score blends precision and recall into one number using their harmonic mean, rewarding models that balance both well.
f1 = 2 * (precision * recall) / (precision + recall)Why Harmonic Mean
The F1 uses a harmonic mean so a low score on either side drags it down. You cannot fake it by acing just one metric.
Get Them in One Call
You do not compute these by hand. The classification report prints precision, recall, and F1 for every class at once.
from sklearn.metrics import classification_report
print(classification_report(y_true, y_pred))Pick the Metric to Optimize
Let the problem decide. Optimize recall when misses hurt, precision when false alarms hurt, and F1 when you need a balance.
Watch the Averaging
With many classes, choose how to average. Macro treats classes equally, weighted accounts for class size. The choice changes the story.
f1_score(y_true, y_pred, average='macro')Quick Check
Let's make sure precision and recall stay straight in your mind.
Recap
Precision trusts your yes, recall catches the positives, and F1 balances both. Let the cost of each mistake guide your choice. 🎯
คำถามที่พบบ่อย
บทเรียน “ความแม่นยำ ความครอบคลุม และ F1” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ความแม่นยำ ความครอบคลุม และ F1” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ความแม่นยำ ความครอบคลุม และ F1”
ชั่งน้ำหนักระหว่างความผิดพลาดแต่ละประเภท คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ความแม่นยำ ความครอบคลุม และ F1” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม
ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ตัวชี้วัดการถดถอย: MAE, MSE, R2
- ถอดรหัสเมทริกซ์ความสับสน
- ความแม่นยำ ความครอบคลุม และ F1
- ROC, AUC และค่าเกณฑ์