Python Machine Learning

Confusion Matrix

Evaluating models

Confusion Matrix

It is a table that is often used to describe the performance of a classification model (or "classifier") on a set of test data for which the true values are known.

Confusion Matrix Example

from sklearn.metrics import confusion_matrix

actual = [2, 0, 2, 2, 0, 1]
predicted = [0, 0, 2, 2, 0, 2]

matrix = confusion_matrix(actual, predicted)
print(matrix)