elbamos / largeVis

An implementation of the largeVis algorithm for visualizing large, high-dimensional datasets, for R
340 stars 62 forks source link

Implement hook for custom distance methods? #50

Closed meowcat closed 6 years ago

meowcat commented 7 years ago

Hi,

from what I can read in the code, implementing a new distance metric for use in searchTrees is only a matter of 1) providing a DenseAnnoySearch implementation 2) providing a corresponding distance function.

(This at least if I do not care about working with sparse matrices. I would have to study sparse matrices better to understand that.)

I have an application where I need a custom, very specific distance metric that I can implement in (R)C(++). I can imagine others also could use this. I could just tack on the functionality, copy/paste some of the code and provide a new searchTreesMyDistance() function but it would be nicer to use a more generalizable way to plug in custom distance functions. Would you consider this?

E.g. with a map<std::string&, distancetype (*)(arma::vec&, arma::vec&)> type construct to register distance types?

elbamos commented 7 years ago

Your interpretation is correct. Actually you should also implement a SparseAnnoySearch.

I don't have the bandwidth to write the plugin code, but I would definitely encourage a PR to add that functionality.

(Or, it's pretty easy to just take the code and make a version of the package with your distance function for your own use.)

On May 23, 2017, at 12:39 PM, meowcat notifications@github.com wrote:

Hi,

from what I can read in the code, implementing a new distance metric for use in searchTrees is only a matter of

providing a DenseAnnoySearch implementation providing a corresponding distance function. (This at least if I do not care about working with sparse matrices. I would have to study sparse matrices better to understand that.)

I have an application where I need a custom, very specific distance metric that I can implement in (R)C(++). I can imagine others also could use this. I could just tack on the functionality, copy/paste some of the code and provide a new searchTreesMyDistance() function but it would be nicer to use a more generalizable way to plug in custom distance functions. Would you consider this?

E.g. with a map<std::string&, distancetype (*)(arma::vec, arma::vec)> type construct to register distance types?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.