Skip to content

Getting float division by zero while classifying #9

Open

Description

@nzee

When I am trying to classify

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

I am getting below error

float division by zero

Activity

  1. codebox commented on Jan 20, 2018

    @codebox
    Owner

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

  2. nzee commented on Jan 23, 2018

    @nzee
    Author

    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.

  3. codebox commented on Jan 23, 2018

    @codebox
    Owner

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

  4. nzee commented on Jan 24, 2018

    @nzee
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions