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

Getting float division by zero while classifying #9

Open
nzee opened this issue Jan 18, 2018 · 4 comments
Open

Getting float division by zero while classifying #9

nzee opened this issue Jan 18, 2018 · 4 comments

Comments

@nzee
Copy link

nzee commented Jan 18, 2018

When I am trying to classify

python bayes.py classify ../testfine.csv spam fine

I am getting below error

float division by zero

@codebox
Copy link
Owner

codebox commented Jan 20, 2018

Please post the full error details, this will tell me which line of code caused the error.

@nzee
Copy link
Author

nzee commented Jan 23, 2018

Hi,
these are the two commands I ran for training:

python bayes.py learn spam ../outspam.csv 500 //Processed 500 documents of type 'spam'
python bayes.py learn fine ../outfine.csv 500 //Processed 500 documents of type 'fine'

And after this i tried this below classify command and get the 'float division by zero' error

python bayes.py classify ../testfine.csv spam fine

float division by zero

Thus I am unable to tell you exactly which line is causing this issue.

@codebox
Copy link
Owner

codebox commented Jan 23, 2018

Please replace the statement 'print ex' in bayes.py with the word 'raise' - that should provide more information about the error

@nzee
Copy link
Author

nzee commented Jan 24, 2018

This is the traceback I got

Traceback (most recent call last):
  File "bayes.py", line 31, in <module>
    mode.output(mode.execute())
  File "/Users/nazimzeeshan/Sites/hacks/spam/bayesian-classifier/classify.py", line 91, in execute
    result = self.p_from_list(pl)
  File "/Users/nazimzeeshan/Sites/hacks/spam/bayesian-classifier/classify.py", line 74, in p_from_list
    return p_product / (p_product + p_inverse_product)
ZeroDivisionError: float division by zero

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

No branches or pull requests

2 participants