We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d5ded33 commit 0840418Copy full SHA for 0840418
1 file changed
algorithms/ml/nearest_neighbor.py
@@ -17,25 +17,25 @@ def distance(x,y):
17
for component in result:
18
sum += component**2
19
return math.sqrt(sum)
20
-
+
21
22
def nearest_neighbor(x, tSet):
23
"""[summary]
24
- Implements the nearest neighbor algorithm
+ Implements the nearest neighbor algorithm
25
26
Arguments:
27
x {[tupel]} -- [vector]
28
tSet {[dict]} -- [training set]
29
30
Returns:
31
[type] -- [result of the AND-function]
32
"""
33
assert isinstance(x, tuple) and isinstance(tSet, dict)
34
current_key = ()
35
- min_d = math.inf
+ min_d = float('inf')
36
for key in tSet:
37
d = distance(x, key)
38
if d < min_d:
39
min_d = d
40
current_key = key
41
- return tSet[current_key]
+ return tSet[current_key]
0 commit comments