bayesian-classifier
bayesian-classifier copied to clipboard
Getting float division by zero while classifying
When I am trying to classify
python bayes.py classify ../testfine.csv spam fine
I am getting below error
float division by zero
Please post the full error details, this will tell me which line of code caused the error.
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.
Please replace the statement 'print ex' in bayes.py with the word 'raise' - that should provide more information about the error
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