From 36007d76da9694bd89fbbb7e8371e807ced2ee6d Mon Sep 17 00:00:00 2001 From: "amaury-charl.reyt" Date: Mon, 30 May 2022 09:26:40 +0200 Subject: [PATCH] New version --- KNN_Mark1.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/KNN_Mark1.py b/KNN_Mark1.py index 022615b..586d15f 100644 --- a/KNN_Mark1.py +++ b/KNN_Mark1.py @@ -6,7 +6,8 @@ def lancer(k, date, temp_moy, temp_ref, donnees): print(k) print(donnees_point) #print(temp_num_jour) - kPlusProches(k, donnees_point, donnees) + lst_k_plus_proches = kPlusProches(k, donnees_point, donnees) + PuissanceMoyenne(lst_k_plus_proches) #estBissextile(an) def lecture(fichier): @@ -18,9 +19,9 @@ def lecture(fichier): lst_ligne = list(ligne_net.split(";")) temp_jour.append(lst_ligne) for i in range(len(temp_jour)): - temp_jour[i][1] = float(temp_jour[i][1]) - temp_jour[i][2] = float(temp_jour[i][2]) - temp_jour[i][3] = float(temp_jour[i][3]) + temp_jour[i][1] = float(temp_jour[i][1]) + temp_jour[i][2] = float(temp_jour[i][2]) + temp_jour[i][3] = float(temp_jour[i][3]) return temp_jour def estBissextile(an): @@ -124,10 +125,11 @@ def distance(donnees, donneespoint, i): z2 = donneespoint[2] return ((d_final)**2)+((y1-y2)**2)+((z1-z2)**2) -def PuissanceMoyenne(lst,dist): +def PuissanceMoyenne(lst_k_plus_proches): """Calcule la moyenne de distances entre les points """ lecture("pic-journalier-consommation.csv") - conso_moy = sum() / len() + conso_moy = sum() / len(lst_k_plus_proches) + return conso_moy def recup1(): k = 5 #value1.get()