Skip to content
Snippets Groups Projects
Commit 6ab4cee3 authored by UMEC Mathieu's avatar UMEC Mathieu
Browse files

adding change of clusters number

parent 745fd20b
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment