Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Duplicate Elements >> matrix_size cause infinite loop #5

Closed
spencebeecher opened this issue Sep 28, 2016 · 0 comments
Closed

Duplicate Elements >> matrix_size cause infinite loop #5

spencebeecher opened this issue Sep 28, 2016 · 0 comments

Comments

@spencebeecher
Copy link
Contributor

When you are dealing with a large number of duplicate items the recursive nature of the alg goes into an infinite loop. Instead of getting the duplicates distributed evenly at a level they are all allocated to the first item in the matrix.

The current fix is not very efficient:

Line ~96 in nearest_search within matrix_distance.py

if scores.sum() < 0.0001 and len(scores) > 0:
    # they are all practically the same
    # we have to do this to prevent infinite recursion
    # TODO: would love an alternative solution
    arg_index = np.random.choice(len(scores), k, replace=False)
else:
    arg_index = np.argsort(scores)[:k]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant