Computing F1 From Raw Predictions
The Larkspur Mail scorecard has one column, F1, and every overnight model has to be entered into it from the raw output, because nobody summarises these runs into counts.
The two lists line up position by position: the first entry of one describes the same email as the first entry of the other, and so on to the end. A 1 means spam and a 0 means ordinary mail, so the first list is the human's verdict and the second is the filter's. Spam - the 1 label - is the positive class.
The team has one rule for this exercise, learned the hard way: the counts must come out of the lists, not out of your head. Hand-written constants have twice been left behind in a notebook, only to be quietly reused on a different test set.
Task: Print the model's F1 score for the spam class - the 1 label - derived from the two lists, as a single number rounded to 4 decimals. Round once, at the very end.
Input
Two lines. The first holds the human labels, each 0 or 1, separated by single spaces. The second holds the model's predictions in the same form. The two lines always hold the same number of entries; the model always flags at least one email and every run contains at least one spam.
Output
One line holding the F1 score, rounded to 4 decimals and printed the way Python prints a float - 0.7273, and 0.5 rather than 0.5000.
Example:
Input:
1 0 1 1 0 1 0 0 1 1
1 0 1 0 1 1 0 0 1 0
Output:
0.7273
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