10000 DOC example of extracting true positive, false negative, etc. (#8469) · maskani-moh/scikit-learn@3d2795b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d2795b

Browse files
jnothmanmaskani-moh
authored andcommitted
DOC example of extracting true positive, false negative, etc. (scikit-learn#8469)
1 parent 99b09ed commit 3d2795b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sklearn/metrics/classification.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ def confusion_matrix(y_true, y_pred, labels=None, sample_weight=None):
236236
[0, 0, 1],
237237
[1, 0, 2]])
238238
239+
In the binary case, we can extract true positives, etc as follows:
240+
>>> tn, fp, fn, tp = confusion_matrix([0, 1, 0, 1], [1, 1, 1, 0]).ravel()
241+
>>> (tn, fp, fn, tp)
242+
(0, 2, 1, 1)
243+
239244
"""
240245
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
241246
if y_type not in ("binary", "multiclass"):

0 commit comments

Comments
 (0)
0