Machine LearningLesson 82Free preview
Confusion Matrix
This lesson is part of Python · All levels
Summary
The confusion matrix is a table that summarizes the results of classification predictions into four categories: positive, positive, negative, and negative. From this table, various metrics such as accuracy, precision, recall, and F1 are calculated. Checking a confusion matrix is more informative than merely looking at accuracy, especially on unbalanced data. sklearn provides a ready-to-use function of the metrics module.
Key points
- The confusion matrix summarizes the correct and incorrect predictions per class.
- TP: positive predicted correct; FP: positive predicted wrong
- The precision = TP/ (TP + FP), the recall = TP/ (TP + FN)
- Accuracy alone can be misleading on unbalanced data.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.