C3_W1_Assignment Exercise 5

I am getting this error on exercise 5:
UnboundLocalError: local variable ‘probability_f’ referenced before assignment
I have set the three earlier uses of probability_f equal to their corresponding pdf functions. I do not have much experience with match statements, so I am having trouble troubleshooting this error. I tried to look into earlier posts about this same error, but most of them ended up being resolved through DM. Can someone please give me some guidance on this?
Thank you

Edit: The error is referring to this part of the code:

Multiply by probability of current feature

    probability *= probability_f

I’m not a mentor for this course, so I can’t see the course materials myself.

But in general, you can’t use a variable before you’ve given it a value. Apparently you have not set a default value for probability_f.

Or, maybe whatever you’re using as the “match” variable has some values that you didn’t expect.

Maybe match isn’t being used correctly, or you’re passing it the wrong variable.

I tried setting probability_f equal to a default value of 1.0 and it gave me the wrong output. The values just remained as 1.0. I believe the parameters are correct when I am calling the functions, so it’s probably the match that is incorrect, but I am not sure how to adjust it properly.

I think you’ll need to wait for help from the community for this course, or one of its mentors.

1 Like

okay, thank you