Spaces:
Runtime error
Runtime error
Commit ·
4258877
1
Parent(s): 65e80b8
feat(metrics): create metrics module for all out metrics used in this project
Browse files- src/utils/metrics.py +14 -0
src/utils/metrics.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
|
| 3 |
+
def euclidean_distance(list1, list2):
|
| 4 |
+
"""
|
| 5 |
+
Computes the Euclidean distance between two lists of numbers.
|
| 6 |
+
|
| 7 |
+
:param list1: The first list of numbers.
|
| 8 |
+
:param list2: The second list of numbers.
|
| 9 |
+
:return: The Euclidean distance as a float.
|
| 10 |
+
"""
|
| 11 |
+
if len(list1) != len(list2):
|
| 12 |
+
raise ValueError("Both lists must be of the same length")
|
| 13 |
+
squared_diff = sum((a - b) ** 2 for a, b in zip(list1, list2))
|
| 14 |
+
return math.sqrt(squared_diff)
|