Coder Social home page Coder Social logo

Comments (5)

wmayner avatar wmayner commented on May 22, 2024

It shouldn't really matter whether the bins of your histograms are indexed by three or any other number of coordinates, as long as you construct the distance matrix appropriately.

Just np.ravel the signatures so that they're 1-dimensional, and build the distance matrix so that the i,jth entry is the ground distance between point i = (x_1, y_1, z_1) and point j = (x_2, y_2, z_2). You'll need a mapping between integer indices and 3D points.

from pyemd.

pclucas14 avatar pclucas14 commented on May 22, 2024

Hi again,

thanks for the fast reply. After looking more closely to the example, I'm unsure as to how I can translate my problem to the histogram setting. Basically I have 2 sets of size N, with a NxN matrix of pairwise distances. In the example, the distance matrix seems to show cost to move from 1 histogram to another, whereas mine are actual distances. Given this information, do you think I can leverage your code ?

Thank you

from pyemd.

wmayner avatar wmayner commented on May 22, 2024

If you take a look at the API section of the README, the distance matrix is exactly that: an N by N matrix that gives the pairwise distance between the histogram bins (the “ground distance”). The EMD between the histograms is the output of the emd function, not one of its arguments.

from pyemd.

pclucas14 avatar pclucas14 commented on May 22, 2024

The only way I can think of adapting this to the histogram setting is by by setting first_historgram to be a vector of size 2Nx1, where the first N are 0's and the last N are 1's (and vice versa for second_histogram).
Then I would need to convert my NxN matrix into a 2Nx2N matrix where the top left and bottom right quadrant are filled with zeros. Note that the 2 sets contain different elements, and I don't have distances between points in the same set.

Unfortunately, that's too much overhead since I have N =~ 2500. You seem to say there is an easy to plugging this in your API. I'd like to apologise, as I cannot cleary see it.

Thanks for the help

from pyemd.

wmayner avatar wmayner commented on May 22, 2024

If you don't want to allow moving mass within a histogram, then yes, you need to pad them with zeros as you described—however, the top-left and bottom-right blocks of the distance matrix should be filled with a value that's higher than any other, not with zero, as that would mean moving mass within a histogram is free (and allowed).

If your histogram just consists of 1s, then your problem is an instance of minimum-cost bipartite matching: you need to find the minimum-cost way of pairing up points in either set. The EMD is more general; you might find better performance with another optimization library that solves that problem specifically. Furthermore, since you're dealing with a 3-dimensional space equipped with some metric, then there are additional constraints on costs between the points; you might be able to exploit that structure to get a faster solution than in the general cost case if you write your own solver.

In any case, none of this requires additional implementation to support multi-dimensional points, so I'm closing this issue.

from pyemd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.