diff --git a/KNN_Mark1.py b/KNN_Mark1.py index 586d15f..6b3027e 100644 --- a/KNN_Mark1.py +++ b/KNN_Mark1.py @@ -1,14 +1,13 @@ from tkinter import * def lancer(k, date, temp_moy, temp_ref, donnees): - moyenne_liste() + donnees, lst_conso = moyenne_liste() donnees_point = [date, temp_moy, temp_ref] print(k) print(donnees_point) - #print(temp_num_jour) + print(donnees) lst_k_plus_proches = kPlusProches(k, donnees_point, donnees) PuissanceMoyenne(lst_k_plus_proches) - #estBissextile(an) def lecture(fichier): temp_jour = [] @@ -84,29 +83,12 @@ def numeroJour(date): def moyenne_liste(): temp_jour = lecture("pic-journalier-consommation.csv") donnees= [] + lst_conso = [] for i in range(len(temp_jour)): temp_jour[i][0] = numeroJour(temp_jour[i][0]) - 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] - 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) - donnees.append([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) - return donnees + donnees.append([temp_jour[i][0], temp_jour[i][2], temp_jour[i][3]]) + lst_conso.append(temp_jour[i][1]) + return donnees, lst_conso def distance(donnees, donneespoint, i): """Fonction qui dit qu'en prenant des points et ben on peut trouver une distance entre 2 point""" @@ -116,19 +98,17 @@ def distance(donnees, donneespoint, i): d2 = 365 - d1 d_final = d1 if d1 > d2: - d_final = d2 - - - y1 = donnees[i][2] - y2 = donneespoint[2] - z1 = donnees[i][3] + d_final = d2 + y1 = donnees[i][1] + y2 = donneespoint[1] + z1 = donnees[i][2] z2 = donneespoint[2] return ((d_final)**2)+((y1-y2)**2)+((z1-z2)**2) def PuissanceMoyenne(lst_k_plus_proches): """Calcule la moyenne de distances entre les points """ lecture("pic-journalier-consommation.csv") - conso_moy = sum() / len(lst_k_plus_proches) + conso_moy =0 # sum() / len(lst_k_plus_proches) return conso_moy def recup1():