mirror of
https://github.com/onyx-and-iris/grokking-algorithms.git
synced 2024-11-15 17:30:52 +00:00
rename variable
This commit is contained in:
parent
adf9534443
commit
c2dab280ac
@ -30,10 +30,10 @@ def knn(point: Point, neighbours):
|
|||||||
neighbour.distance = np.linalg.norm(point.array - neighbour.array)
|
neighbour.distance = np.linalg.norm(point.array - neighbour.array)
|
||||||
logger.debug(f"{neighbour.identifier}: {neighbour.distance}")
|
logger.debug(f"{neighbour.identifier}: {neighbour.distance}")
|
||||||
|
|
||||||
average = 0
|
total = 0
|
||||||
for n in sorted(neighbours, key=lambda x: x.distance)[:K]:
|
for n in sorted(neighbours, key=lambda x: x.distance)[:K]:
|
||||||
average += n.sold
|
total += n.sold
|
||||||
return average / K
|
return total / K
|
||||||
|
|
||||||
|
|
||||||
neighbours = [
|
neighbours = [
|
||||||
|
Loading…
Reference in New Issue
Block a user