def UpdateStats(stats, t0, curr_lp, K, z, c, steps, gt_z, map_z, verbose): stats['lp'].append(curr_lp) stats['K'].append(K) stats['z'].append(z) stats['c'].append(c) curr_time = time.clock() - t0 stats['times'].append(curr_time) if verbose: print('Step: ' + str(steps) + ' Time: ' + str(curr_time) + ' LP: ' + str(curr_lp) + ' K: ' + str(K)) if gt_z.size > 0: stats['NMI'].append(StatsUtil.NMI(gt_z, map_z)) return stats
def LearnSynthForDataset(synth): # Hyperparameters alpha = 10; kappa = 0.0001; nu = 1; sigsq = 0.01; pass_limit = 30; D = NormalizeConn(synth.D) # Normalize connectivity to zero mean, unit var # Compute our ddCRP-based parcellation Z = WardClustering.ClusterTree(D, synth.adj_list) _,dd_stats = initdd.InitializeAndRun(Z, D, synth.adj_list, range(1,21), alpha, kappa, nu, sigsq, pass_limit, synth.z, 0) DC = dd_stats['NMI'][-1] DC_K = dd_stats['K'][-1] # Ward Clustering, using number of clusters discovered from our method WC = StatsUtil.NMI(synth.z, WardClustering.Cluster(Z, DC_K)) return (WC,DC,DC_K)