C2_W2_Assignment_ # UNQ_C5 GRADED FUNCTION: initialize

Please help.

Getting
“ValueError: math domain error” when calculating best_probs[i,0]
(#UNQ_C5 GRADED FUNCTION: initialize)

Think this might be because either A or B matrix has ‘0’ value.
I Can’t figure out why.

When I created the emission matrix (# UNQ_C4 GRADED FUNCTION: create_emission_matrix). My B matrix had all ‘0’ values even though expected output had all non-zero values. But it still passed all the test.

Lab ID : eenhccvugatr

Thanks.

hi @sujitimepass

can you post a screenshot of the error you are mentioning for UNQC5 and the output you got UNQC4

please make sure not to post any grade cell codes here.

Regards
DP

for UNQC4, I suppose you are probably using incorrect function keys to get the desired output, although part of desired output matches, but if you notice your row values are dataframe are all 0.0

passing a unittest doesn’t mean your codes are always correct.

Also the best_probs codes are incorrect, you are using incorrect functions to calculate the best_probs.

Also remember each grade cells comes with its own call arguments which you are suppose to use for that cell

Regards
DP

“for UNQC4, I suppose you are probably using incorrect function keys to get the desired output”
Can you elaborate on that?

“math.log is incorrect function code used here for best probs, your error states to see the instructions above.”

The instructions above does ask me to use “math.log”

Screen Shot 2024-09-25 at 12.38.38 PM

This is my lab ID: eenhccvugatr

Thanks

1 Like

please DM your codes.

click on my name and then message.

Hi @sujitimepass

Sorry for the delay in response and sorry for the incorrect statement about the math.log, that code is correct. I thought the codes from week 4 assignment and mixed it up.

Now addressing your code

Your issue lies with UNQC4 codes for two codes lines.

  1. for code line
    Go through each column (words) YOU HAVE USED number of tags where as instruction mentions you to calculate words, so change num tags to num_words for the second iteration code line.

  2. Next one of the key function you have used is incorrect for the code mentions you to check if the (POS tag, word) tuple exist as a key in emission counts, so here you used
    if key in emission count, you are not suppose to use here emission_count but name it as keys functio recall name for emission count, so it would be emis_keys right?

Your UNQC5 code threw error because of the UNQC4 error as you used a dictionary to recall a key function.

Keep Learning!!

Regards
DP

Thanks DP. Appreciate the help. That resolved it :+1:

1 Like