src.evaluation_metric.rand_index¶
- src.evaluation_metric.rand_index(pred_clusters: torch.Tensor, gt_classes: torch.Tensor) torch.Tensor [source]¶
Rand index measurement for clusters.
Rand index is computed by the number of instances predicted in the same class with the same label \(n_{11}\) and the number of instances predicted in separate classes and with different labels \(n_{00}\), normalized by the total number of instances pairs \(n(n-1)\):
\[\text{rand index} = \frac{n_{11} + n_{00}}{n(n-1)}\]- Parameters
pred_clusters –
\((b\times n)\) predicted clusters. \(n\): number of instances.
e.g. [[0,0,1,2,1,2] [0,1,2,2,1,0]]
gt_classes –
\((b\times n)\) ground truth classes
e.g. [['car','car','bike','bike','person','person'], ['bus','bus','cat', 'sofa', 'cat', 'sofa' ]]
- Returns
\((b)\) clustering purity