All problems

Which Class Do We Fail On?

hardPythonML MetricsDictionaries

Riverbend Wildlife Trust runs camera traps, and a model labels every photo with the animal it thinks it has seen. Volunteers label the same photos by hand, so each photo carries a true species and a guess. One overall score is no use to them: what they need is the species the model keeps getting wrong, because that is the one short of training photos.

Task: For every species that really appears in the photos, print the share of its photos the model got wrong.

Input

The first line holds an integer n, the number of photos. Each of the next n lines holds two labels separated by a single space: the true species first, the model's guess second. Labels are short lowercase words.

Output

One line per species, in alphabetical order: the name, one space, and its error share with exactly two digits after the decimal point. A species appears only if it turns up as a true label — one the model merely guessed at gets no line. A species the model never got wrong still gets its line, showing 0.00.

Example:

Input:
6
cat cat
cat dog
dog dog
dog dog
bird cat
bird bird

Output:
bird 0.50
cat 0.50
dog 0.00

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…