C1_W2_Assignment Medical Diagnosis Course

Hello,

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:

"Error: Wrong output in true_negatives
2 Tests passed
1 Tests failed

Assertion Error: Not all tests were passed for true_negatives. Check your equations and avoid using global variables inside the function."

Has anyone else encountered the same problem? What am I doing wrong?

Thank you!

2 Likes

Hi @BBK87 ,

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.

2 Likes

Hello,

Thank you. I did look at it carefully. I still couldn’t understand the problem. Thank you for your help in advance, very much appreciated.

1 Like

Hello @BBK87.

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.

Regards
DP

1 Like

Hi @BBK87,

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 :wink: Just check that function first.
As @Deepti_Prasad asked, sharing screenshots of the complete error may shed some light.

2 Likes

@BBK87

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.

Regards
DP

1 Like

I figured out the problem(s). Thanks.

1 Like

Yes, after looking through it for the third time, I figured it out. Thanks for your support!

1 Like

Kindly let us know where was the mistake and how did you correct it, so when other learners face similar issues they get help from your thread…

Regards
DP

1 Like

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.

2 Likes

Thanks for sharing. I am glad you figured it out.

1 Like