Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion machine_learning/similarity_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
2. distance between the vector and the nearest vector (float)
"""
import math
from typing import List, Union

import numpy as np

Expand All @@ -30,7 +31,9 @@ def euclidean(input_a: np.ndarray, input_b: np.ndarray) -> float:
return math.sqrt(sum(pow(a - b, 2) for a, b in zip(input_a, input_b)))


def similarity_search(dataset: np.ndarray, value_array: np.ndarray) -> list:
def similarity_search(
dataset: np.ndarray, value_array: np.ndarray
) -> List[List[Union[List[float], float]]]:
"""
:param dataset: Set containing the vectors. Should be ndarray.
:param value_array: vector/vectors we want to know the nearest vector from dataset.
Expand Down