How are precision and recall better metrics than accuracy for classification in my example?
Your calculation is correct, but you forgot to ask yourself one question: why should we consider &quot;red&quot; as the positive class? Precision and recall can be calculated for every class (i.e. considering the current class as positive), as opposed to accuracy.
So if we take &quot;blue&quot; as positive we get:

precision = NaN (because there's 0 predicted positive)
recall = 0 / 2 = 0

Usually after that one would calculate micro- and/or macro-precision/recall:

macro-precision = NaN because the precision is NaN for blue
micro-precision = totalTP / totalTP+totalFP = 8/10
macro-recall = ( 1 + 0 ) / 2 = 0.5
micro-recall = totalTP / totalTP+totalFN = 8/10

By definition, micro-performance favours the majority class so it's still high. However macro-performance would clearly show the problem that accuracy cannot show.