def visualize(path, levels, threshold, ccore_enabled, **kwargs): sample = read_sample(path) clique_instance = clique(sample, levels, threshold, ccore=ccore_enabled) clique_instance.process() cells = clique_instance.get_cells() clique_visualizer.show_grid(cells, sample)
def visualize(path, levels, threshold, ccore_enabled, **kwargs): sample = read_sample(path) clique_instance = clique(sample, levels, threshold, ccore=ccore_enabled) clique_instance.process() cells = clique_instance.get_cells() clique_visualizer.show_grid(cells, sample)
def template_clustering(data_path, intervals, density_threshold, **kwargs): print("Sample: '%s'." % os.path.basename(data_path)) data = read_sample(data_path) clique_instance = clique(data, intervals, density_threshold) clique_instance.process() clusters = clique_instance.get_clusters() noise = clique_instance.get_noise() cells = clique_instance.get_cells() print([len(cluster) for cluster in clusters]) clique_visualizer.show_grid(cells, data) visualizer = cluster_visualizer() visualizer.append_clusters(clusters, data) visualizer.append_cluster(noise, data, marker='x') visualizer.show()
intervals = 5 # Density threshold threshold = 0 clique_instance = clique(data_values, intervals, threshold) clique_instance.process() clique_cluster = clique_instance.get_clusters() noise = clique_instance.get_noise() cells = clique_instance.get_cells() print("Amount of clusters:", len(clique_cluster)) for cluster in clique_cluster: print(cluster) labelList = [0] * 200 j = 1 for cluster in clique_cluster: for x in cluster: labelList[x] = j j = j + 1 labels = np.array(labelList) clique_visualizer.show_grid(cells, data_values) visualizer = cluster_visualizer_multidim() visualizer.append_clusters(clique_cluster, data_values) BETACV = betacv.betacv(data, labels) print(BETACV)
zeros[each] = 5 # for each in clique_cluster[4]: # zeros[each] = 1 g_answer = zeros #print(g_answer) sum = 0 for i in range(len(g_truth)): if g_answer[i] == g_truth[i]: sum += 1 rate = sum / len(g_truth) print(rate) #print(g_truth) #print(g_answer) print("Amount of clusters:", len(clique_cluster)) print(clique_cluster) print(f"运行时间:{(t2-t1)/1e6}ms") #运行时间 # 显示由算法形成的网格 clique_visualizer.show_grid(cells, TestData) # 显示聚类结果 clique_visualizer.show_clusters(TestData, clique_cluster, noise) # show clustering results # 准确率 print(f"准确率:{Coopcheckdiv(np.array(g_answer),data_M[:,0])}")