Although your answer if for Multiclass class classification different from what was asked in the question, it really helped a lot as I was searching how to compute the accuracy for multiclass classification.