import numpy as np ; import matplotlib.pyplot as plt

# import direct connaissant les entêtes (N°dep,longitude,latitude,Nbre habitants)
ardeche = np.loadtxt('ardeche_sup_1000.csv', delimiter=';', skiprows=1, dtype=str)
ardeche = np.char.replace(ardeche, ',', '.'); ardeche=ardeche.astype(float)

# initialise la classe à 0 pour chaque ville et initialise arbitrairement 3 centroïde
colk=np.ones((len(ardeche[:,1]),1))
Cent=np.array([[4.2,44.4],[4.5,44.8],[4.8,45.2]])
def affichage(Dep,Clas,CdG,n): # fonction affichage des villes et centroïdes
    plt.figure(n)
    plt.scatter(CdG[:,0],CdG[:,1],c="red",s=150);plt.scatter(Dep[:,1],Dep[:,2],c=Clas);
    plt.xlabel("Longitude en °");plt.ylabel("Latitude en °");
    plt.title("Villes de plus de 1000 habitants");plt.grid(True);plt.show()

affichage(ardeche,colk,Cent,1) # affiche la carte et centroïdes initiaux
