Computing Precision From Raw Predictions
Same overnight runs at Larkspur Mail, same pair of raw lists, but now the support team wants their own question answered: when this model puts an email in the junk folder, how much should a customer trust that call?
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.
Nobody builds a confusion matrix for these runs, so the counts have to come out of the lists themselves, whatever length tonight's test set happens to be.
Task: Print the model's precision for the spam class - the 1 label - over the run. Print the raw number; no rounding is asked for.
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, and the model always flags at least one email.
Output
One line holding the precision as a float, printed raw - 0.8, and 0.6666666666666666 when the division does not terminate.
Example:
Input:
1 0 1 1 0 1 0 0 1 1
1 0 1 0 1 1 0 0 1 0
Output:
0.8
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