def test_plot_sim_matrix(self): g = nx.karate_club_graph() coms = algorithms.louvain(g) coms2 = algorithms.label_propagation(g) viz.plot_sim_matrix([coms, coms2], evaluation.adjusted_mutual_information) plt.savefig("cluster.pdf") os.remove("cluster.pdf")
# plot the network clusters viz.plot_network_clusters(nx_g, pred_coms, pos, figsize=(5, 5)) plt.title(f'{name} algo of {graph_name}, AMI = {round(ami_score, 3)}') plt.show() # plot the graph viz.plot_community_graph(nx_g, pred_coms, figsize=(5, 5)) plt.title(f'Communities for {name} algo of {graph_name}.') plt.show() #%% analysis plots coms = [ground_truth_com] for name, results in results_dict.items(): coms.append(results['pred_coms']) #%% viz.plot_sim_matrix(coms,evaluation.adjusted_mutual_information) plt.show() viz.plot_com_properties_relation(coms, evaluation.size, evaluation.internal_edge_density) plt.title('Internal Edge Density vs. Size') plt.show() viz.plot_com_properties_relation(coms, evaluation.size, evaluation.average_internal_degree) plt.title('Internal Average Degree vs. Size') plt.show() viz.plot_com_stat(coms, evaluation.internal_edge_density) plt.show() #%% df_nodes.to_csv('ais/nodes_from_cd.csv', index=False)
def draw_cluster_heatmap(list_of_communities): clustermap = viz.plot_sim_matrix(list_of_communities, evaluation.adjusted_mutual_information) plt.savefig("communities/clustermap.png")