From c2dab280ac7e1c6e34b8fbaf8260ea371f63c736 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 17 Jan 2024 18:16:56 +0000 Subject: [PATCH] rename variable --- chapter12/loaves.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chapter12/loaves.py b/chapter12/loaves.py index cb299d2..c93027e 100644 --- a/chapter12/loaves.py +++ b/chapter12/loaves.py @@ -30,10 +30,10 @@ def knn(point: Point, neighbours): neighbour.distance = np.linalg.norm(point.array - neighbour.array) logger.debug(f"{neighbour.identifier}: {neighbour.distance}") - average = 0 + total = 0 for n in sorted(neighbours, key=lambda x: x.distance)[:K]: - average += n.sold - return average / K + total += n.sold + return total / K neighbours = [