Contient les fichiers et dossiers liés au TP en Apprentissage portant sur les algorithmes de clustering.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

visualisation_plots_generator2.py 984B

1234567891011121314151617181920212223242526272829
  1. import os
  2. import csv
  3. import matplotlib.pyplot as plt
  4. try:
  5. os.mkdir("dataset_to_plots")
  6. except FileExistsError:
  7. pass
  8. files_names = os.listdir(path="dataset")
  9. for file_name in files_names:
  10. with open("dataset/"+file_name, newline='') as f:
  11. rows = csv.reader(f, delimiter=";", quoting=csv.QUOTE_NONNUMERIC)
  12. points = []
  13. for row in rows:
  14. points+=[row]
  15. x = [p[0] for p in points]
  16. y = [p[1] for p in points]
  17. plt.figure(figsize=(10.36, 5.56)) # specifying size of the visualisation
  18. if file_name=="y1.csv":
  19. plt.scatter(x, y, marker="o", color="black", s=0.003)
  20. else:
  21. plt.scatter(x, y, marker="o", color="black", s=10)
  22. plt.xlabel("Abcisses")
  23. plt.ylabel("Ordonnees")
  24. plt.title("Graphe de visualisation des points du fichier " + file_name)
  25. plt.savefig("dataset_to_plots/" + file_name.split(sep=".")[0] + ".png")
  26. plt.show()
  27. plt.close()