Reputation: 11
Today I have finished processing some data and came to conclusion that I have the following final tables containing:
Counts. | |
---|---|
True Positive | 23070 |
True Negative | 4503 |
False Positive | 28 |
False Negative | 34 |
I am trying to construct a confusion matrix here, scikit-learn.confusion_matrix style, but I cant figure out how. Can I use Matplotlib for this instead? Do you guys ever come to his type of quest? I believe we can draw it somehow. Thank you!
Upvotes: 1
Views: 1811
Reputation: 2233
With scikit-learn.confusion_matrix
You can get the confusion matrix by
cm = confusion_matrix(y_true, y_pred)
And the confusion matrix is already in the form
TP|FN
FP|TN
You can use seaborn's heatmap to plot the data:
import seaborn as sns
sns.heatmap(cm, annot=True, cmap='Blues')
If you already have the data then try storing it in a list of list then plot the data using seaborn:
cm_data = [[23070, 34], [4503, 28]]
sns.heatmap(cm_data, annot=True, cmap='Blues', fmt='d')
Upvotes: 4