I am having trouble with Exercises 4 and 5 to be precise of the Week 2 Assignment of AI for Medical Diagnosis course, but I see the same problem with Exercise 1, which is supposed to be an “example”.
The exercise 1, which is supposed to be an example to begin with gives the following error(s) when I run it:
Did you do the exercise “C1_W2_Lab_1_roc_curve _and_threshold”?
If you look at it carefully, it may help you solve this error. If that does not work, let me know, and I will gladly work with.
Good luck.
Please post screenshots of the complete error you are getting for the exercises you mentioned, and make sure not to include any codes from the assignment while sharing the error.
The error snippet you had shared seems to indicate that there was an issue with how you designed the function for true_negatives. The exercise I had pointed to earlier clearly defines that. You can also check how you did the function for true_positives. Something very minor can cause such an error Just check that function first.
As @Deepti_Prasad asked, sharing screenshots of the complete error may shed some light.
to understand your error, one needs to know what is a global variable
a global variable is a variable that is declared outside any function and is accessible throughout the entire program. These variables can make your code harder to understand, test, and debug. They can also lead to less maintainable and reusable code. So, you must use global variables with care and control.
Unlike local variables, which are confined to the scope of a specific function, global variables retain their values across multiple function calls.
If you still didn’t get through DM your codes for exercise 1 where you are encountering the error. Click on my name and then message. Do not post codes here.
In the computational TN formula, I was not using an integer threshold. That was why the error message was saying “avoid using global variables”.
Also, as Saad_El-Din kindly pointed out, the TN formula is already introduced with correct thresholds in “C1_W2_Lab_1_roc_curve _and_threshold” assignment, after revisiting that exercise lab and spotting the formula, I saw the mistake I made.
One more note: In Exercises 4 and 5; the asked functions (TP, FP, TN, FN) in the code are already introduced earlier, it is important to use them - in other words reuse them - as they are, without any modifications.