Earth Mover's distance in python
After digging through online resources, I am finally able to find two ways to calculate the Earth Mover’s distance writing in Python.
Interface between C implementation and Python modules
This approach is recommended for its speed. Basically, we add a file interface between the author’s C implementation and out own python modules.
- Update the author’s code to fulfil our requirements. Example: link
- Call through python modules. Example: link
Through Linear Programming Package (GLPK)
There are several steps to go.
- Install GLPK (could be done through
brew
) - Install Pulp
- Run the following script
The result is:
160.542762808