C1_W2_exercise2

I passed 12 tests, but failed 3 tests as shown in the attached screen. I checked my implementation and did not have any idea on how to change the loglikelihood dictionary. Any idea from anyone?

1 Like

I have got to see you implementation of exercise 2 so maybe I can find a problem with it, send it to me on a private message!

1 Like

Here are some problems:

Increment the number of positive words by the count for this (word, label) pair

the same for negative words! Not increment by 1 but by the count!

Here: Calculate D_pos, the number of positive documents - the comments tell you to use train_y!

In the last for loop, use directly the lookup function no need for assignments to variable and if conditions, just follow exactly the comments provided!

2 Likes

@gent.spah Thanks for advice. I have revised the code (attached). 12 tests passed. 3 tests failed (attached). If I take out if condition now in the last for loop, the program will fail with key error. I can take out later after I know my code error.

1 Like

You are not allowed to post solutions publicly! I am telling you just use the lookup function directly as per the comments above, no need for if’s there. Try to read the comments from scratch again!

2 Likes

I have read comments again and revised the code. 12 Tests passed. 3 Test failed. I do not have any idea to change the code further.

1 Like

It’s probably time to look at your code. We can’t do that on a public thread, but I just sent you a private message (DM) about how to proceed.

3 Likes

To close the loop on the public thread, there was a simple typo in one of the expressions that was causing the problems. Should be all sorted now! :nerd_face:

3 Likes