All problems

The Confusion Matrix

mediumPythonML Metrics

Before the managers can argue about rates, Harborline's analyst prints the raw breakdown of a batch: four counts that say exactly what happened, with nothing averaged away. Every parcel falls into exactly one of the four, so the four always add back up to the size of the batch — which is the first thing she checks.

Task: Print the four counts.

Input

The first line holds an integer n, the number of parcels. Each of the next n lines holds two values separated by a single space: the true label first, the model's label second. Both are 1 (banned item inside) or 0 (clean).

Output

Four lines in this order, each a label, one space, and a whole number:

TP X — dangerous parcels the model flagged. FP X — clean parcels it flagged anyway. FN X — dangerous parcels it let through. TN X — clean parcels it correctly left alone.

A cell with nothing in it still gets its line, showing 0.

Example:

Input:
5
1 1
0 1
1 0
0 0
1 1

Output:
TP 2
FP 1
FN 1
TN 1

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…