What is Confusion Matrix?

Confusion matrix (or error matrix) is a specific table layout that allows the visualization of the detailed performance of a machine learning model, especially in a classification problem. 

For example, the following figure shows a binary classification confusion matrix with label 0 and 1. The first entry 13 indicates the model predicted 13 examples as label 0 and the ground truth labels for those examples are also 0.


scikit-learn provides the function to output the confusion matrix of a classification model for the ground truth labels (y_true in the following) and predicted labels (y_pred in the following).



from sklearn.metrics import confusion_matrix
print(confusion_matrix(y_true, y_pred))

No comments:

Post a Comment