From 1c05a87a6c41236a8488e5a624cc4495dc3cfb0b Mon Sep 17 00:00:00 2001 From: VANDEPOELE Enzo Date: Thu, 12 May 2022 09:35:07 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'kplusproche.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kplusproche.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/kplusproche.py b/kplusproche.py index de81df7..b924e07 100644 --- a/kplusproche.py +++ b/kplusproche.py @@ -1,19 +1,13 @@ -# -*- coding: utf-8 -*- -""" -Éditeur de Spyder - -Ceci est un script temporaire. -""" -def kPlusProches(k,donnees_point,temp_jour): - """erreur""" - voisins = [] - if k > len(temp_jour[0]): - k = len(temp_jour[0]) - energy = temp_jour.pop() - energy.sort - for i in range(len(temp_jour[0])): - d = distance(temp_jour[i],donnees_point) - voisins.append((d, i)) - voisins.sort() - return [voisins[i][1] for i in range(k)] - +def kPlusProches(k,donnees_point,temp_jour): + """erreur""" + voisins = [] + if k > len(temp_jour[0]): + k = len(temp_jour[0]) + energy = temp_jour.pop() + energy.sort + for i in range(len(temp_jour[0])): + d = distance(temp_jour[i],donnees_point) + voisins.append((d, i)) + voisins.sort() + return [voisins[i][1] for i in range(k)] +