Skip to content

Commit

Permalink
Replace min.inf by float(inf)
Browse files Browse the repository at this point in the history
  • Loading branch information
danghai committed Aug 2, 2018
1 parent d5ded33 commit 0840418
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions algorithms/ml/nearest_neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ def distance(x,y):
for component in result:
sum += component**2
return math.sqrt(sum)


def nearest_neighbor(x, tSet):
"""[summary]
Implements the nearest neighbor algorithm
Implements the nearest neighbor algorithm
Arguments:
x {[tupel]} -- [vector]
tSet {[dict]} -- [training set]
Returns:
[type] -- [result of the AND-function]
"""
assert isinstance(x, tuple) and isinstance(tSet, dict)
current_key = ()
min_d = math.inf
min_d = float('inf')
for key in tSet:
d = distance(x, key)
if d < min_d:
min_d = d
current_key = key
return tSet[current_key]
return tSet[current_key]

0 comments on commit 0840418

Please sign in to comment.