Skip to content

Instantly share code, notes, and snippets.

View bjoernkjoshanssen's full-sized avatar

Bjørn Kjos-Hanssen bjoernkjoshanssen

View GitHub Profile
@vhxs
vhxs / jaccard_metric_counterexample.py
Last active June 25, 2023 04:05
Jaccard metric spaces cannot be isometrically embedded in Euclidean space
import numpy as np
from random import sample
# The Jaccard distance is truly a metric: https://arxiv.org/pdf/1612.02696.pdf
def jaccard_distance(set1: set, set2: set):
union_size = len(set1.union(set2))
intersection_size = len(set1.intersection(set2))
return 1 - (intersection_size / union_size)