You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contrib/machine-learning/confusion-matrix.md
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
-
Confusion Matrix - A confusion matrix is a fundamental performance evaluation tool used in machine learning to assess the accuracy of a classification model. It is an N x N matrix, where N represents the number of target classes.
1
+
## Confusion Matrix
2
+
3
+
A confusion matrix is a fundamental performance evaluation tool used in machine learning to assess the accuracy of a classification model. It is an N x N matrix, where N represents the number of target classes.
2
4
3
5
For binary classification, it results in a 2 x 2 matrix that outlines four key parameters:
4
6
1. True Positive (TP) - The predicted value matches the actual value, or the predicted class matches the actual class.
@@ -20,15 +22,18 @@ To implement the confusion matrix in Python, we can use the confusion_matrix() f
20
22
The function returns a 2D array that represents the confusion matrix.
21
23
We can also visualize the confusion matrix using a heatmap.
22
24
25
+
```python
23
26
# Import necessary libraries
24
27
import numpy as np
25
-
from sklearn.metrics import confusion_matrix,classification_report
28
+
from sklearn.metrics import confusion_matrix,classification_report
26
29
import seaborn as sns
27
30
import matplotlib.pyplot as plt
28
31
29
32
# Create the NumPy array for actual and predicted labels
0 commit comments