MCPcopy Create free account
hub / github.com/TPCD/DCCL / evaluate_clustering

Function evaluate_clustering

project_utils/cluster_utils.py:22–36  ·  view source on GitHub ↗
(y_true, y_pred)

Source from the content-addressed store, hash-verified

20# Evaluation Criteria
21# -------------------------------
22def evaluate_clustering(y_true, y_pred):
23
24 start = time.time()
25 print('Computing metrics...')
26 if len(set(y_pred)) < 1000:
27 acc = cluster_acc(y_true.astype(int), y_pred.astype(int))
28 else:
29 acc = None
30
31 nmi = nmi_score(y_true, y_pred)
32 ari = ari_score(y_true, y_pred)
33 pur = purity_score(y_true, y_pred)
34 print(f'Finished computing metrics {time.time() - start}...')
35
36 return acc, nmi, ari, pur
37
38
39def cluster_acc(y_true, y_pred, return_ind=False):

Callers

nothing calls this directly

Calls 2

cluster_accFunction · 0.85
purity_scoreFunction · 0.85

Tested by

no test coverage detected