Browse Source

Dépot : Modif sur KNN_Mark1

master
enzo.vandepoele 3 years ago
parent
commit
d56f115d42
  1. 38
      KNN_Mark1.py

38
KNN_Mark1.py

@ -1,9 +1,9 @@
from tkinter import * from tkinter import *
def lancer(date, temp_moy, temp_ref): def lancer(k, date, temp_moy, temp_ref, temp_num_jour):
moyenne_liste() moyenne_liste()
donnees_point = [date, temp_moy, temp_ref] donnees_point = [date, temp_moy, temp_ref]
kPlusProches(k, donnees_point,temp_num_jour) kPlusProches(k, donnees_point, temp_num_jour)
estBissextile(an) estBissextile(an)
def lecture(fichier): def lecture(fichier):
@ -87,30 +87,30 @@ def numeroJour(date):
def moyenne_liste(): def moyenne_liste():
temp_jour = lecture("pic-journalier-consommation.csv") temp_jour = lecture("pic-journalier-consommation.csv")
temp_num_jour = [] temp_num_jour = []
for i in range(365): for i in range(len(temp_jour)):
temp_jour[i][0] = numeroJour(temp_jour[i][0]) temp_jour[i][0] = numeroJour(temp_jour[i][0])
for l in range(len(temp_jour)): lst_conso = []
lst_conso = [] lst_temp_moy = []
lst_temp_moy = [] lst_temp_ref = []
lst_temp_ref = [] moy_conso = 0
moy_conso = 0 moy_temp_moy = 0
moy_temp_moy = 0 moy_temp_ref = 0
moy_temp_ref = 0 for l in range(1,366):
for m in range(len(temp_jour)): for m in range(len(temp_jour)):
if temp_jour[l][0] == i+1: if temp_jour[m][0] == l:
lst_conso.append(temp_jour[l][1]) lst_conso.append(temp_jour[l][1])
lst_temp_moy.append(temp_jour[l][2]) lst_temp_moy.append(temp_jour[l][2])
lst_temp_ref.append(temp_jour[l][3]) lst_temp_ref.append(temp_jour[l][3])
for n in range(len(lst_conso)): for n in range(len(lst_conso)):
moy_conso += lst_conso[n] moy_conso += lst_conso[n]
moy_temp_moy += lst_temp_moy[n] moy_temp_moy += lst_temp_moy[n]
moy_temp_ref += lst_temp_ref[n] moy_temp_ref += lst_temp_ref[n]
print(lst_conso)
moy_conso = moy_conso / len(lst_conso) moy_conso = moy_conso / len(lst_conso)
moy_temp_moy = moy_temp_moy / len(lst_temp_moy) moy_temp_moy = moy_temp_moy / len(lst_temp_moy)
moy_temp_ref = moy_temp_ref / len(lst_temp_ref) 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): def distance(temp_jour, donneespoint):
"""Fonction qui dit qu'en prenant des points et ben on peut trouver une distance entre 2 point""" """Fonction qui dit qu'en prenant des points et ben on peut trouver une distance entre 2 point"""
x1 = temp_jour[0] x1 = temp_jour[0]
@ -185,7 +185,7 @@ entree4.grid()
label9= Label(fenetre, text="Conso", bg="yellow") 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() canvas1.grid()
label9.grid(pady=10) label9.grid(pady=10)

Loading…
Cancel
Save