domid.utils package¶
Submodules¶
domid.utils.mean_std module¶
domid.utils.perf_cluster module¶
- class domid.utils.perf_cluster.PerfCluster(num_classes)[source]¶
Bases:
PerfClassif
Clustering Performance
- classmethod hungarian_algorithm(cluster_pred_scalar, cluster_true_scalar, cost)[source]¶
This function takes two arrays as input, encodes any string elements to integers, and applies the Hungarian Algorithm to find the optimal assignment between the two arrays.
- classmethod cal_acc(model, loader_te, device, max_batches=None)[source]¶
Compare the cluster assignment against the domain labels (d) as well as against the class labels (y). Compute the two respective confusion matrices and overall accuracy measurements (after finding the optimal matching with the cluster labels).
- Parameters:
model –
loader_te –
device – for final test, GPU can be used
max_batches – maximum number of iterations for data loader, used to probe performance with less computational burden. default None, which means to traverse the whole dataset
- Returns:
accuracy - clusters vs. y
confusion matrix - clusters vs. y
accuracy - clusters vs. d
confusion matrix - clusters vs. d