Skip to content
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

Chamming distance is added #278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Chamming distance is added #278

wants to merge 1 commit into from

Conversation

Eldar7
Copy link

@Eldar7 Eldar7 commented Feb 12, 2018

Due to recent request https://groups.google.com/forum/#!topic/annoy-user/FheMHkmgjpk chamming distance was added to available distances.

Chamming is a correct hamming distance:
chamming([a,b,c,d],[a,c,b,d]) = 2

@Eldar7
Copy link
Author

Eldar7 commented Feb 12, 2018

ouch, it worked fine with f29296c commit.

@erikbern
Copy link
Collaborator

What's Chamming distance? Can you send a link to an explanation?

@Eldar7
Copy link
Author

Eldar7 commented Feb 12, 2018

It is regular hamming distance https://en.m.wikipedia.org/wiki/Hamming_distance that can be applied to any vectors, not only to binary vectors.

Due to wiki:
The Hamming distance between:
"karolin" and "kathrin" is 3.

@erikbern
Copy link
Collaborator

Can you get this one to pass the tests?

@lbertolotti
Copy link

# -*- coding: utf-8 -*-
"""
Spyder Editor
"""
import annoy
import inspect

u = annoy.AnnoyIndex(5,metric='hamming')
u.add_item(0,'12346')
u.add_item(1,'12345')
u.build(1)
u.save('tree')
u.get_n_items()

In:u.get_distance(0,1)
Out: 0.0

@Eldar7
Copy link
Author

Eldar7 commented May 21, 2018

@erikbern , ok, I'll try to make this one to pass the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants