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

ZeroDivisionError when computing Jaccard or Cosine distances #1

Closed
rsgoncalves opened this issue Nov 18, 2018 · 1 comment
Closed
Labels
help wanted Extra attention is needed

Comments

@rsgoncalves
Copy link

For Jaccard distance

  File "/users/home/docs/strdist.py", line 67, in <listcomp>
    distances = np.array([[jac.distance(w1, w2) for w1 in tokens] for w2 in tokens])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/similarity/jaccard.py", line 32, in distance
    return 1.0 - self.similarity(s0, s1)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/similarity/jaccard.py", line 51, in similarity
    return 1.0 * inter / len(union)
ZeroDivisionError: float division by zero

And for Cosine distance

  File "/users/home/docs/strdist.py", line 75, in <listcomp>
    distances = np.array([[cos.distance(w1, w2) for w1 in tokens] for w2 in tokens])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/similarity/cosine.py", line 35, in distance
    return 1.0 - self.similarity(s0, s1)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/similarity/cosine.py", line 49, in similarity
    self._norm(profile0) * self._norm(profile1))
ZeroDivisionError: float division by zero
@luozhouyang luozhouyang added the help wanted Extra attention is needed label Dec 3, 2018
@luozhouyang
Copy link
Owner

Hi @rsgoncalves I have fixed this ZeroDivisionError.
This bug was caused by shigle_based.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants