Week 1 Exercise 5 grading issue

The instructions for Exercise 5 say:

You can use Python’s built-in round function to avoid very long floats but this is up to you and your grade will not be affected by this. [emphasis mine]

However, when not rounded, compute_breed_proportions returns 5/10, with the grader output:

Failed test case: Incorrect 'probs_dict' when using the whole 'df_all_breeds' dataframe.
{0: 0.348, 1: 0.391, 2: 0.261},
but got:
{2: 0.2608695652173913, 0: 0.34782608695652173, 1: 0.391304347826087}.

If anyone needs it, this is my code:

# Save the probability of each class (breed) in the probabilities dict rouding to 3 decimal places
probs_dict[breed] = prob_class

Hey @Amuck_Gorilla,
Welcome, and we are glad that you could become a part of our community :partying_face:


1 Like

Hey @Amuck_Gorilla,
I checked the notebook, and you are indeed correct. If we don’t round-off the probabilities, the grader throws an error. Let me raise an issue regarding this with the team. Either, we can modify the markdown, or the grader, to resolve this discrepancy. Thanks a lot for spotting it out. In the meanwhile, you can just round-off the probabilities to get a complete score for the assignment.


Hi guys,

Thanks for spotting this issue. I decided to just ask the learner to round up to 3 decimal places in the markdown, because it is the simplest solution.

You can take a look at the assignment. I added the following piece of text:

You must use Python’s built-in round function to round each value in the dictionary to 3 decimal places. The call is round(x,3), where x is a float.