From d56f115d42a8387447b994b91f60dfb0f0434457 Mon Sep 17 00:00:00 2001 From: "enzo.vandepoele" Date: Thu, 19 May 2022 09:48:03 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9pot=20:=20Modif=20sur=20KNN=5FMark1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KNN_Mark1.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/KNN_Mark1.py b/KNN_Mark1.py index a50aa4b..a42350f 100644 --- a/KNN_Mark1.py +++ b/KNN_Mark1.py @@ -1,9 +1,9 @@ from tkinter import * -def lancer(date, temp_moy, temp_ref): +def lancer(k, date, temp_moy, temp_ref, temp_num_jour): moyenne_liste() donnees_point = [date, temp_moy, temp_ref] - kPlusProches(k, donnees_point,temp_num_jour) + kPlusProches(k, donnees_point, temp_num_jour) estBissextile(an) def lecture(fichier): @@ -87,30 +87,30 @@ def numeroJour(date): def moyenne_liste(): temp_jour = lecture("pic-journalier-consommation.csv") temp_num_jour = [] - for i in range(365): + for i in range(len(temp_jour)): temp_jour[i][0] = numeroJour(temp_jour[i][0]) - for l in range(len(temp_jour)): - lst_conso = [] - lst_temp_moy = [] - lst_temp_ref = [] - moy_conso = 0 - moy_temp_moy = 0 - moy_temp_ref = 0 - for m in range(len(temp_jour)): - if temp_jour[l][0] == i+1: - lst_conso.append(temp_jour[l][1]) - lst_temp_moy.append(temp_jour[l][2]) - lst_temp_ref.append(temp_jour[l][3]) + lst_conso = [] + lst_temp_moy = [] + lst_temp_ref = [] + moy_conso = 0 + moy_temp_moy = 0 + moy_temp_ref = 0 + for l in range(1,366): + for m in range(len(temp_jour)): + if temp_jour[m][0] == l: + lst_conso.append(temp_jour[l][1]) + lst_temp_moy.append(temp_jour[l][2]) + lst_temp_ref.append(temp_jour[l][3]) for n in range(len(lst_conso)): moy_conso += lst_conso[n] moy_temp_moy += lst_temp_moy[n] moy_temp_ref += lst_temp_ref[n] - print(lst_conso) moy_conso = moy_conso / len(lst_conso) moy_temp_moy = moy_temp_moy / len(lst_temp_moy) moy_temp_ref = moy_temp_ref / len(lst_temp_ref) - temp_num_jour.append([i, moy_conso, moy_temp_moy, moy_temp_ref]) - + temp_num_jour.append([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) + return print(temp_num_jour) + def distance(temp_jour, donneespoint): """Fonction qui dit qu'en prenant des points et ben on peut trouver une distance entre 2 point""" x1 = temp_jour[0] @@ -185,7 +185,7 @@ entree4.grid() label9= Label(fenetre, text="Conso", bg="yellow") -bouton1 = Button(canvas1, text="Tester", command=lancer(value2.get, value3.get, value4.get), width=15, height=2, bg="cyan").grid(pady=10) +bouton1 = Button(canvas1, text="Tester", command=lancer(value1.get, value2.get, value3.get, value4.get, moyenne_liste()), width=15, height=2, bg="cyan").grid(pady=10) canvas1.grid() label9.grid(pady=10)