ถอดรหัสเมทริกซ์ความสับสน
ผลบวกจริง ผลบวกเท็จ ผลลบจริง และผลลบเท็จ
ถอดรหัสเมทริกซ์ความสับสน เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Beyond a Single Number
For classifiers, one accuracy score hides too much. The confusion matrix lays out exactly which predictions were right and which were wrong. 🧩
A Simple Grid
The matrix is a small grid: rows are the true classes, columns are the predicted ones. Each cell counts how often that pairing happened.
from sklearn.metrics import confusion_matrix
confusion_matrix(y_true, y_pred)True Positives
A true positive is when the model says yes and the answer really is yes. These are the wins you want to maximize.
True Negatives
A true negative is when the model says no and the truth is also no. The model correctly left this case alone.
False Positives
A false positive is a false alarm: the model predicted yes, but the truth was no. Think of flagging a healthy patient as sick.
False Negatives
A false negative is a miss: the model said no while the truth was yes. Picture letting a real fraud slip through unnoticed.
Two Kinds of Mistakes
Notice the two error types differ in cost. A false positive and a false negative are rarely equal, so the matrix keeps them separate.
Where Accuracy Lives
Accuracy is just the correct cells over the total. It is the diagonal divided by everything, which is why it can mask rare errors.
accuracy = (TP + TN) / (TP + TN + FP + FN)Read the Off-Diagonal
The most useful cells sit off the diagonal: they show where the model confuses one class for another, pointing to its weak spots.
See It as a Heatmap
For many classes, plot the matrix as a heatmap. Bright off-diagonal squares instantly reveal which labels get mixed up most.
from sklearn.metrics import ConfusionMatrixDisplay
ConfusionMatrixDisplay.from_predictions(y_true, y_pred)Your Metric Foundation
Almost every classification metric is built from these four counts. Master the confusion matrix and the rest follow naturally.
Quick Check
Let's make sure each cell of the matrix is crystal clear.
Recap
The confusion matrix splits results into true and false, positive and negative. Those four counts power every classification metric. 🎯
คำถามที่พบบ่อย
บทเรียน “ถอดรหัสเมทริกซ์ความสับสน” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ถอดรหัสเมทริกซ์ความสับสน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ถอดรหัสเมทริกซ์ความสับสน”
ผลบวกจริง ผลบวกเท็จ ผลลบจริง และผลลบเท็จ คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ถอดรหัสเมทริกซ์ความสับสน” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม
ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ตัวชี้วัดการถดถอย: MAE, MSE, R2
- ถอดรหัสเมทริกซ์ความสับสน
- ความแม่นยำ ความครอบคลุม และ F1
- ROC, AUC และค่าเกณฑ์