From 6ab4cee3c0f192ab416acfc2e2b1661ba09c96f8 Mon Sep 17 00:00:00 2001 From: local_comparaison <mathieu.umec@inrae.fr> Date: Wed, 30 Aug 2023 09:05:54 +0200 Subject: [PATCH] adding change of clusters number --- Visualisation_des_donnes_de_mapping.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Visualisation_des_donnes_de_mapping.py b/Visualisation_des_donnes_de_mapping.py index d583f20..60f2e77 100644 --- a/Visualisation_des_donnes_de_mapping.py +++ b/Visualisation_des_donnes_de_mapping.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt import seaborn as sns #### Importation des données -def Distance_matrix_clustering (input_file,val_infini=50.2): +def Distance_matrix_clustering (input_file,val_infini=50.2, n_clusters=5): dataframe= pd.read_excel(input_file,index_col = 0) print(dataframe.head()) @@ -48,7 +48,7 @@ def Distance_matrix_clustering (input_file,val_infini=50.2): ##### Traitement de la matrice de distance - nombre_de_clusters=7 + nombre_de_clusters=n_clusters clustering = AgglomerativeClustering(n_clusters = nombre_de_clusters, metric = "precomputed",linkage="complete").fit(matrice_pour_traitement) #results_clustering=pd.DataFrame ({'in': [clustering.labels_] }) results_clustering=clustering.labels_ @@ -71,7 +71,7 @@ def Distance_matrix_clustering (input_file,val_infini=50.2): ###### visualisation - l_identifiants_de_graphes=[111,111,111,111,111,111,111,111] + l_identifiants_de_graphes=[111,111,111,111,111,111,111,111,111,111,111,111,111,111] plt.figure(figsize=(15, 3)) for num_graph in range (nombre_de_clusters): @@ -82,8 +82,8 @@ def Distance_matrix_clustering (input_file,val_infini=50.2): print(matrice_pour_traitement[Liste_d_indice_trier_selon_cluster[num_graph][0]][Liste_d_indice_trier_selon_cluster[num_graph][sous_indice]]) plt.subplot(indentifiant_graphe) plt.plot(Liste_de_nom_trier_selon_cluster[num_graph],donnes_graph ) - - plt.suptitle('les differents clusters n=7 ') + plt.tick_params(axis='x', rotation=90, size=0.08,labelsize = 7) + plt.suptitle('les differents clusters n='+str(n_clusters)) plt.show() #Distance_matrix_clustering("C:\\Users\\mumec\\Desktop\\Mini_codes\\DistanceMatrix_compose_interet.xlsx") -- GitLab