how to calculate the missclassification rate/ Accuracy rate for clustering? I am working with cluster models. I tried to find an accuracy rate/misclassification rate manually. I found an example that confuses me.
The example can be accessed from here. I think the author find the accuracy rate wrongly. I think it should sum the diagonal values of the matrix (the result of the table function), then divide it by the total number of observations. Am I correct? or do I misunderstand something?

For context, the cluster table in question is this one, for the Iris dataset:
$$\matrix{\textrm{setosa}&\textrm{versicolor}&\textrm{virginica}\\0&48&4\\0&2&46\\50&0&0}$$
The main source of confusion here is that the discovered clusters need not be in the same order as the true groups. Indeed, if we appropriately rearrange the clusters/rows, we can see that accuracy can be expressed as the new trace:
$$\matrix{\textrm{setosa}&\textrm{versicolor}&\textrm{virginica}\\50&0&0\\0&48&4\\0&2&46}$$
In this case, it is clear how to reorder the clusters to match the true groups.  In the more general case, it might not be so clear how to assign clusters to groups, but you can look at metrics such as the Rand index instead.
