Average Log Loss Over a Batch
One prediction's charge is a curiosity; the number Kestrel Freight actually trains against is the charge over a whole batch of jobs. It is the average of the per-prediction charges, not their total, so that a batch of thirty jobs and a batch of three hundred can be put side by side and a longer test run does not look like a worse model. Each job is charged the same way as before: by how much probability the model put on the outcome that actually happened, as a negative natural logarithm, so a confident mistake costs far more than a cautious one.
Task: Print the average log loss across the batch.
Input
The first line holds one integer n, the number of jobs in the batch, where 1 <= n <= 1000. Then come n lines, each holding two numbers separated by a single space: the true outcome, 1 for a late delivery and 0 for an on-time one, and the probability of lateness the model gave that job, strictly between 0 and 1.
Output
One line holding the average charge rounded to 4 decimal places, with no label. Natural logarithms throughout.
Example:
Input:
2
1 0.8
0 0.2
Output:
0.2231
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