bayesian-classifier icon indicating copy to clipboard operation
bayesian-classifier copied to clipboard

Getting float division by zero while classifying

Open nzee opened this issue 7 years ago • 4 comments

When I am trying to classify

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

I am getting below error

float division by zero

nzee avatar Jan 18 '18 09:01 nzee

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

codebox avatar Jan 20 '18 07:01 codebox

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.

nzee avatar Jan 23 '18 12:01 nzee

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

codebox avatar Jan 23 '18 13:01 codebox

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

nzee avatar Jan 24 '18 08:01 nzee