C3-W1-#6 stuck help :(


I have been stuck for a long time on the question #6. I can’t seem to figure out what to put in the none cases and I always end up with the local variable ‘probability_f’ referenced before assignment error.
So basically:


in the params_dict = i write in order : [breed][feature][value]. Ex : breed, height|weight, mu

for probability_f = I put the pdf or pmf (x, value, value). Ex : pdf_gaussian x, mu, sigma

for the last sentence ; *= i put probability_f

Thank you in advance, its been like 1 hour that I’m stuck there

Your error means that you referenced the probability_f variable before you assigned it. This means that you did not assign it properly before referencing it. I will advise that you carefully go over your code and make sure you assign the variables properly, following the instructions. Try to also indent properly.
Also, take note that sharing solution code publicly is not allowed in the community.

I didn’t modify the lab indentation, so I don’t think that can be the issues and all my 3 probability_f functions are equal to the relevant pdf/pmf given the distribution and the estimated parameters. I’m confused…

Just to be clear, we are talking about the prob_of_X_given_C function, right? So, it has a local scope, being that the block is within a function. You should make sure that all three functions for probability_f are called with the right and complete arguments (three in each case). This should resolve your error, provided that all the previous functions in your notebook are correctly defined. You can also try restarting your kernel and running all the cells prior to the current one, and then run this one.

Often the problem with this assignment is passing the wrong values to the function, such that none of the cases match.