diff --git a/k_plus_proche.py b/k_plus_proche.py index 25ca8be..6554934 100644 --- a/k_plus_proche.py +++ b/k_plus_proche.py @@ -11,8 +11,8 @@ def kPlusProche(point,lst_representative): Paramètres de sortie : Une liste triée en fonction de la distance dont les éléments sont des tuples (distance, indice du tableau original)""" voisins = [] - for i in range(len(lst_representative)): - d = distance (point, lst_representative[1][i] ) + for i in range(len(lst_representative)): + d = distance (point, lst_representative[i][0] ) voisins.append((d, i)) voisins.sort() # Pour un couple, sort trie d'abord en fonction de la première valeur, donc la distance return voisins @@ -23,7 +23,4 @@ def PuissanceMoyenne(lst_trie,k,lst_ref): k = len(lst_trie) for i in range(0,k): somme=somme+lst_ref[lst_trie[i][1]][1] - return somme/k - -lst_trie=kPlusProche((1,2,6),[(1,5,9,8),(9,6,2,8),(3,5,6,42)]) -printPuissanceMoyenne(lst_trie,1,[((1,5,9),8),((9,6,2),8),((3,5,6),42)]) \ No newline at end of file + return somme/k \ No newline at end of file