Separate a zero score from an undefined metric

Type each count alongside the label that gives it meaning. · 217 words

A zero metric score is a real, defined result. It says that the model received no credit under the metric's formula. Consider a museum app that recommends four objects for a visitor. None of the four is relevant to the visitor's interests. Precision measures the share of recommendations that are relevant: relevant recommendations divided by all recommendations. Here, precision is 0 / 4 = 0. This is a valid zero because the model made four recommendations, so the denominator is positive. It also gives useful information: every recommendation was wrong. A zero therefore does not mean that the metric could not be computed.

An undefined metric is different because its formula lacks enough information to produce a number. For the same museum app, recall measures how many relevant objects were found out of all relevant objects. Suppose the catalog contains no relevant objects for this visitor, and the app retrieves none. Recall would be 0 / 0, which is undefined rather than ordinary zero. Software libraries sometimes adopt a special rule and report 0, but that is a reporting convention, not a value obtained by the usual division. An empty test set similarly makes accuracy undefined because there are no predictions to divide by. Report such cases as not applicable and check the data before comparing models.

Check your recall

If a retriever returns four recommendations and none is relevant, what is its precision, and is that value defined?

Check your answer

Precision is 0 / 4 = 0. It is a valid, defined zero because four recommendations were made. If there were also no relevant items to retrieve, recall would instead be undefined because it would require dividing 0 by 0.

Sources and credits

Original KeyTouch lesson. Background reading · Google · Classification metrics.