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
RuntimeWarning: divide by zero encountered in log #174
Comments
Is this an issue given the latest release v3.2.2? |
I got the same issue using Python 3.8.5, numpy 1.20.1 and pyLDAvis 3.2.2 on macOS BigSur 11.2.2. However I did not use GSDMM but visualized data with the "bring your own model" functionality. |
Do you have a Jupyter notebook available that will reproduce the error? I'd like to reproduce the error, then implement a fix showing the error is handled. |
Yes this zip file contains an example notebook with the issue. |
So I am not seeing the error with your example. Python 3.9.2 on BigSur Can you please provide me the exact error stack trace you are seeing? I am pretty sure all we need to do is change instance of
|
I always get the following three RuntimeWarning messages when calling the pyLDAvis.prepare function:
Installed packages:
|
- removing unused variables - providing for np.log(0) fix - also fixing flake issue with 'l'
RuntimeWarning: divide by zero encountered in log #174 - providing for np.log(0) fix (removing pd.eval())
Err..forgot to run the pytest before committing...TBC |
@TimSchopf Please give the recent commit a try
|
I tested the commit and got the following RuntimeWarning messages:
|
Can you try upgrading to Note:
:1: RuntimeWarning: divide by zero encountered in log So my approach may need to change to address that scenario versus a true division by zero |
Try this code in a notebook by itself:
'1.2.3' Create some mock data:
And now, should return
topic 0 1 Now, let's create the condition for divide by zero
..and now run the division by zero scenario
topic 0 1
topic 0 1 where then ..
topic 0 1 |
After upgrading to |
My solution will need to change then to address only np.log(0), but it looks like it will correctly handle inside pd.eval() (see no warning below, only for np.log(0) directly.
topic term 0 1 2 topic 0 1 term 0 1 2 term topic 0 1 :36: RuntimeWarning: divide by zero encountered in log |
np.log(0): throws RuntimeWarning: divide by zero encountered in log. but np.log(pd.eval(..)) handles correctly in pandas==1.2.3 and numpy==1.20.1
When passing a GSDMM short text clustering model to pyLDAvis for visualisation, I sometimes get 'divide by zero' warnings even though the visualisation is created successfully. How can these be resolved? Is it because of a small corpus? I am usually building these models on around 100 documents containing 10-15 tokens each. Screenshot attached, would appreciate help on this!
I am using Python 3.7 on MacOS Catalina version 10.15.3.
The text was updated successfully, but these errors were encountered: