-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom distances #21
Comments
Currently I have no plan to implement a custom distance. But, since I know that a custom distance is important for some applications, I would like to implement a custom distance into C++ API in future. But, I do not think that a custom distance defined by slow python is an effective way, because the distance function largely affects the search time. |
Thanks. Just to check, if I want to add a custom distance myself in the C++ without adding all the architecture for it, could I potentially just replace the following lines: NGT/lib/NGT/PrimitiveComparator.h Lines 48 to 65 in 79ba11c
and refer to my custom distance as "l2" ? (My distance is similar to L2) Or would there be a lot more I would need to replace? Cheers, |
You are right. You do not need to update other part of the source code. But you have to care about implementing your function. Objects (vector data) are automatically stored as a 16-byte boundary object with zero padding in the index. NGT/lib/NGT/PrimitiveComparator.h Line 48 in 79ba11c
The size above is the byte length of the 16-byte boundary object. You cannot get the original size of the object in the function. For example, when you specify 3-dimensional floating point object to create an empty index, the size of the function’s parameter is 16 and the added forth floating point of the object is always zero. |
If you use the default cmake definitions, you have to replace NGT/lib/NGT/PrimitiveComparator.h Line 78 in 79ba11c
or NGT/lib/NGT/PrimitiveComparator.h Line 118 in 79ba11c
, because AVX must be available. |
is there any plan to add support for braycurtis and canberra distances? thanks |
We have no plan to implement braycurtis and canberra distances. However, it might not be so difficult to implement the distances by yourself referring to this PR #91. |
Hi,
I was wondering if you were planning to add support for custom distance_type's in the python API? I have a complicated function in python that I wish to use as a custom distance metric and am interested in the scalability of this package.
For example, I would like to set distance_type=func.
As with sklearn's NearestNeighbors, the function typically has arguments for each point input (can be input as 2D numpy vectors). Would this work for NGT?
The text was updated successfully, but these errors were encountered: