Skip to content

Commit

Permalink
Merge pull request #276 from spotify/angular-holes
Browse files Browse the repository at this point in the history
fix issue with holes in the index and angular distance
  • Loading branch information
erikbern authored Feb 5, 2018
2 parents 9c5370d + 420a3d7 commit 505a747
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/annoylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ inline void two_means(const vector<Node*>& nodes, int f, Random& random, bool co
T di = ic * Distance::distance(p, nodes[k], f),
dj = jc * Distance::distance(q, nodes[k], f);
T norm = cosine ? get_norm(nodes[k]->v, f) : 1.0;
if (!(norm > T(0))) {
continue;
}
if (di < dj) {
for (int z = 0; z < f; z++)
p->v[z] = (p->v[z] * ic + nodes[k]->v[z] / norm) / (ic + 1);
Expand Down
3 changes: 3 additions & 0 deletions test/accuracy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@ def _test_index(self, dataset, exp_accuracy):
def test_glove_25(self):
self._test_index('glove-25-angular', 69.00)

def test_nytimes_16(self):
self._test_index('nytimes-16-angular', 80.00)

def test_fashion_mnist(self):
self._test_index('fashion-mnist-784-euclidean', 90.00)

0 comments on commit 505a747

Please sign in to comment.