Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d7e56d1

Browse files
committedAug 28, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1898766 commit d7e56d1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
 

‎machine_learning/similarity_search.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def similarity_search(
4444
dataset: np.ndarray,
4545
value_array: np.ndarray,
4646
distance_func: DistanceFunction = euclidean,
47-
k: int = 1
47+
k: int = 1,
4848
) -> List[List[Union[List[float], float]]]:
4949
"""
5050
:param dataset: Set containing the vectors. Should be ndarray.
@@ -143,10 +143,7 @@ def similarity_search(
143143
for value in value_array:
144144
distances = [distance_func(value, data_point) for data_point in dataset]
145145
nearest_indices = np.argsort(distances)[:k]
146-
answer.append([
147-
[dataset[i].tolist(), distances[i]]
148-
for i in nearest_indices
149-
])
146+
answer.append([[dataset[i].tolist(), distances[i]] for i in nearest_indices])
150147

151148
return answer[0] if len(answer) == 1 else answer
152149

0 commit comments

Comments
 (0)
Please sign in to comment.