Simple method for calculating the euclidean distance between two points, with type np.ndarray. Example: >>> a = np.array([1, 0, -2]) >>> b = np.array([2, -1, 1]) >>> euclidean(a, b) 3.3166247903554
(point_1: np.ndarray, point_2: np.ndarray)
| 336 | |
| 337 | |
| 338 | def euclidean(point_1: np.ndarray, point_2: np.ndarray) -> float: |
| 339 | """ |
| 340 | Simple method for calculating the euclidean distance between two points, |
| 341 | with type np.ndarray. |
| 342 | |
| 343 | Example: |
| 344 | >>> a = np.array([1, 0, -2]) |
| 345 | >>> b = np.array([2, -1, 1]) |
| 346 | >>> euclidean(a, b) |
| 347 | 3.3166247903554 |
| 348 | """ |
| 349 | return float(np.sqrt(np.sum(np.square(point_1 - point_2)))) |
| 350 | |
| 351 | |
| 352 | def get_distances(descriptors: np.ndarray, base: int) -> list[tuple[int, float]]: |