From 1c34f86e3aaed5a87125f7cebdc31ed30f3114b3 Mon Sep 17 00:00:00 2001 From: BaptisteBrd <75663738+BaptisteBrd@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:00:51 +0100 Subject: [PATCH] knn fst commit --- knn.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 knn.py diff --git a/knn.py b/knn.py new file mode 100644 index 0000000..cffe512 --- /dev/null +++ b/knn.py @@ -0,0 +1,14 @@ +import numpy as np + +def distance_matrix(a,b): + sx = np.sum(a**2, axis=1, keepdims=True) + sy = np.sum(b**2, axis=1, keepdims=True) + dists = np.sqrt(-2 * a.dot(b.T) + sx + sy.T) + return dists + + + + + +if __name__ == "__main__" : + -- GitLab