|
|
@ -1,12 +1,12 @@ |
|
|
|
from tkinter import * |
|
|
|
|
|
|
|
def lancer(k, date, temp_moy, temp_ref, temp_num_jour): |
|
|
|
def lancer(k, date, temp_moy, temp_ref, donnees): |
|
|
|
moyenne_liste() |
|
|
|
donnees_point = [date, temp_moy, temp_ref] |
|
|
|
print(k) |
|
|
|
print(donnees_point) |
|
|
|
#print(temp_num_jour) |
|
|
|
kPlusProches(k, donnees_point, temp_num_jour) |
|
|
|
kPlusProches(k, donnees_point, donnees) |
|
|
|
#estBissextile(an) |
|
|
|
|
|
|
|
def lecture(fichier): |
|
|
@ -25,12 +25,6 @@ def lecture(fichier): |
|
|
|
|
|
|
|
def estBissextile(an): |
|
|
|
"""Fonction estBissextile qui prend en paramètre l’année à vérifier et qui renvoie True si elle est bissextile, False sinon""" |
|
|
|
# an_base = an |
|
|
|
# an = an//4 |
|
|
|
# if an*4 == an_base: |
|
|
|
# return True |
|
|
|
# else: |
|
|
|
# return False |
|
|
|
return an % 4 == 0 |
|
|
|
|
|
|
|
def kPlusProches(k,donnees_point,donnees): |
|
|
@ -41,28 +35,10 @@ def kPlusProches(k,donnees_point,donnees): |
|
|
|
k = len(donnees) |
|
|
|
voisin=[] |
|
|
|
for i in range(len(donnees)): |
|
|
|
voisin.append(distance(donnees, donnees_point)) |
|
|
|
voisin.sorted |
|
|
|
return [voisins[i] for i in range(k)] |
|
|
|
|
|
|
|
|
|
|
|
# for j in range(k): |
|
|
|
# voisin.append([None]) |
|
|
|
|
|
|
|
# for i in range(len(temp_num_jour)): |
|
|
|
# MN = distance(temp_num_jour[i],donnees_point) |
|
|
|
# for l in range(k): |
|
|
|
# if voisin[l][1] == None or MN<voisin[l][4]: |
|
|
|
# pass |
|
|
|
# print(voisin) |
|
|
|
# for m in range(k-l): |
|
|
|
# print(voisin) |
|
|
|
# a_placer = voisin[l] |
|
|
|
# print(voisin) |
|
|
|
# voisin[m][1] = [temp_num_jour[i][0], temp_num_jour[i][1], temp_num_jour[i][2], temp_num_jour[i][4], MN] |
|
|
|
# print(voisin) |
|
|
|
# voisin[m+1][1]= a_placer |
|
|
|
# return voisin |
|
|
|
voisin.append(distance(donnees, donnees_point, i)) |
|
|
|
voisin.sort() |
|
|
|
return [voisin[i] for i in range(k)] |
|
|
|
|
|
|
|
|
|
|
|
def numeroJour(date): |
|
|
|
an_mois_jour = list(date.split("-")) |
|
|
@ -106,7 +82,7 @@ def numeroJour(date): |
|
|
|
|
|
|
|
def moyenne_liste(): |
|
|
|
temp_jour = lecture("pic-journalier-consommation.csv") |
|
|
|
temp_num_jour = [] |
|
|
|
donnees= [] |
|
|
|
for i in range(len(temp_jour)): |
|
|
|
temp_jour[i][0] = numeroJour(temp_jour[i][0]) |
|
|
|
lst_conso = [] |
|
|
@ -128,12 +104,12 @@ def moyenne_liste(): |
|
|
|
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([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) |
|
|
|
return temp_num_jour |
|
|
|
donnees.append([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) |
|
|
|
return donnees |
|
|
|
|
|
|
|
def distance(temp_num_jour, donneespoint): |
|
|
|
def distance(donnees, donneespoint, i): |
|
|
|
"""Fonction qui dit qu'en prenant des points et ben on peut trouver une distance entre 2 point""" |
|
|
|
x1 = temp_num_jour[0] |
|
|
|
x1 = donnees[i][0] |
|
|
|
x2 = donneespoint[0] |
|
|
|
d1 = x1-x2 |
|
|
|
d2 = 365 - d1 |
|
|
@ -142,9 +118,9 @@ def distance(temp_num_jour, donneespoint): |
|
|
|
d_final = d2 |
|
|
|
|
|
|
|
|
|
|
|
y1 = temp_num_jour[2] |
|
|
|
y2 = donneespoint[1] |
|
|
|
z1 = temp_num_jour[3] |
|
|
|
y1 = donnees[i][2] |
|
|
|
y2 = donneespoint[2] |
|
|
|
z1 = donnees[i][3] |
|
|
|
z2 = donneespoint[2] |
|
|
|
return ((d_final)**2)+((y1-y2)**2)+((z1-z2)**2) |
|
|
|
|
|
|
|