Assignment: Probability Distributions / Naive Bayes

Hi everyone,

I got a score of 0 for all the functions in the assignment. The grader output is as follows :
There was a problem compiling the code from your notebook.
Details : name ‘example_dog’ is not defined

However, all of my answers matched those in “Expected output”. I triple checked everything in the Jupyter notebook, and the variable “example_dog” is defined when I run it in a cell.

Please help. Thank you for your time, patience and attention.

Hello, Khai.

Welcome to the Discourse forum! I am not a mentor for that course and have not taken it, so don’t know the details of that assignment. But since no-one else has responded yet, I can give you some general help in “reading the tea leaves” for that error message.

If everything works when you run it locally, but fails when you submit to the grader, it means that your code is not general in some way: the grader uses different test cases and somehow that causes your code to malfunction. Examples of errors that can cause that type of non-generality are:

  1. Hard-coding your implementation to fit some of the dimensions of the input objects.
  2. Referencing global variables directly from the body of your functions. E.g. if a reference to an object like a dictionary gets passed as an argument to your function and you directly use the global definition of the object that happened to get passed in the notebook, then it fails in the grader if a different value is passed.

Please have another careful look through your code, especially in the cell that defines example_dog, and see if any of the things I described above might apply. E.g. if example_dog is first assigned a value in an “if” or “else” clause, think about ways that the boolean conditions might not be met with different test inputs. The code that assigns a value to example_dog must not be executed when the grader runs the code, so you need to figure out how that could happen.

1 Like