Spaces:
Running
Running
Joshua Lochner
commited on
Commit
•
b309907
1
Parent(s):
a197a49
Move `jaccard` to utils
Browse files- src/utils.py +7 -0
src/utils.py
CHANGED
@@ -173,3 +173,10 @@ class InterruptibleTaskPool:
|
|
173 |
sleep(.1)
|
174 |
for p in procs:
|
175 |
logger.info(f'Process status: {p}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
sleep(.1)
|
174 |
for p in procs:
|
175 |
logger.info(f'Process status: {p}')
|
176 |
+
|
177 |
+
|
178 |
+
def jaccard(x1, x2, y1, y2):
|
179 |
+
# Calculate jaccard index
|
180 |
+
intersection = max(0, min(x2, y2)-max(x1, y1))
|
181 |
+
filled_union = max(x2, y2) - min(x1, y1)
|
182 |
+
return intersection/filled_union if filled_union > 0 else 0
|