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

Fixes divided by zero when w_star_count==0 #2259

Merged
merged 2 commits into from
Jan 11, 2019

Conversation

allenyllee
Copy link
Contributor

If w_star_count==0, it will throw exception of divided by zero

@menshikh-iv
Copy link
Contributor

Thanks for PR @allenyllee 👍

@@ -73,6 +73,9 @@ def log_conditional_probability(segmented_topics, accumulator, with_std=False, w
m_lc_i = np.log(((co_occur_count / num_docs) + EPSILON) / (w_star_count / num_docs))
except KeyError:
m_lc_i = 0.0
except ZeroDivisionError:
# if w_star_count==0, it will throw exception of divided by zero
Copy link
Owner

@piskvorky piskvorky Jan 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is true for num_docs == 0.

@allenyllee @menshikh-iv can you add a comment why m_lc_i = 0.0 is the correct solution when a "division by zero" occurs?

It's not obvious to me why this happens, and why such fix is doing the right thing.

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.

3 participants