|
@ -1,12 +1,12 @@ |
|
|
from tkinter import * |
|
|
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() |
|
|
moyenne_liste() |
|
|
donnees_point = [date, temp_moy, temp_ref] |
|
|
donnees_point = [date, temp_moy, temp_ref] |
|
|
print(k) |
|
|
print(k) |
|
|
print(donnees_point) |
|
|
print(donnees_point) |
|
|
#print(temp_num_jour) |
|
|
#print(temp_num_jour) |
|
|
kPlusProches(k, donnees_point, temp_num_jour) |
|
|
kPlusProches(k, donnees_point, donnees) |
|
|
#estBissextile(an) |
|
|
#estBissextile(an) |
|
|
|
|
|
|
|
|
def lecture(fichier): |
|
|
def lecture(fichier): |
|
@ -41,29 +41,11 @@ def kPlusProches(k,donnees_point,donnees): |
|
|
k = len(donnees) |
|
|
k = len(donnees) |
|
|
voisin=[] |
|
|
voisin=[] |
|
|
for i in range(len(donnees)): |
|
|
for i in range(len(donnees)): |
|
|
voisin.append(distance(donnees, donnees_point)) |
|
|
voisin.append(distance(donnees, donnees_point, i)) |
|
|
voisin.sorted |
|
|
voisin.sorted |
|
|
return [voisins[i] for i in range(k)] |
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
def numeroJour(date): |
|
|
def numeroJour(date): |
|
|
an_mois_jour = list(date.split("-")) |
|
|
an_mois_jour = list(date.split("-")) |
|
|
|
|
|
|
|
@ -106,7 +88,7 @@ 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 = [] |
|
|
donnees= [] |
|
|
for i in range(len(temp_jour)): |
|
|
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]) |
|
|
lst_conso = [] |
|
|
lst_conso = [] |
|
@ -128,12 +110,12 @@ def moyenne_liste(): |
|
|
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([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) |
|
|
donnees.append([temp_jour[l-1][0], moy_conso, moy_temp_moy, moy_temp_ref]) |
|
|
return temp_num_jour |
|
|
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""" |
|
|
"""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] |
|
|
x2 = donneespoint[0] |
|
|
d1 = x1-x2 |
|
|
d1 = x1-x2 |
|
|
d2 = 365 - d1 |
|
|
d2 = 365 - d1 |
|
@ -142,9 +124,9 @@ def distance(temp_num_jour, donneespoint): |
|
|
d_final = d2 |
|
|
d_final = d2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y1 = temp_num_jour[2] |
|
|
y1 = donnees[i][2] |
|
|
y2 = donneespoint[1] |
|
|
y2 = donneespoint[2] |
|
|
z1 = temp_num_jour[3] |
|
|
z1 = donnees[i][3] |
|
|
z2 = donneespoint[2] |
|
|
z2 = donneespoint[2] |
|
|
return ((d_final)**2)+((y1-y2)**2)+((z1-z2)**2) |
|
|
return ((d_final)**2)+((y1-y2)**2)+((z1-z2)**2) |
|
|
|
|
|
|
|
|