Replies: 2 comments 1 reply
-
We have this in the SDK, so shall we move it across? class EarthMoversDistance(DistanceMetric):
"""
Earth movers distance (EMD), aka Wasserstein 1-distance, between samples from two distributions.
"""
@property
def distance(self) -> float:
"""
Calculate the EMD between two 1d histograms.
Returns:
The earth mover's distance.
"""
return wasserstein_distance(self.x, self.y) |
Beta Was this translation helpful? Give feedback.
0 replies
-
As for comparing to pyemd, this was done when the code was swapped: synthesized-io/synthesized#564 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So currently we have two ways of computing EMD, the first is found here which essentially assumes each category is equidistant from one another:
insight/src/synthesized_insight/metrics/metrics.py
Lines 197 to 241 in 8d17059
The second is here which I think takes an already binned set of variables and uses the centre of the bins to calculate the distance:
insight/src/synthesized_insight/metrics/distance.py
Lines 358 to 405 in f88cf96
I think we should have a way of calculating distances for affine variables even if they aren't binned. We should check these metrics agree with pyemd.
Beta Was this translation helpful? Give feedback.
All reactions