AI for Medicine W1 Assignment

Please kindly explain to me how to solve the Week 1 assignment of data prevention leakage.

Hi, Noor.

There are people listening who would like to help, but it’s not really fair to ask such a general question. Where are we supposed to start with the question posed that way?

The notebooks here all have quite complete explanations and instructions. If you’ve read through the notebook carefully starting from the beginning, please ask a more specific question about the first point at which you are having trouble understanding something.

Regards,
Paul

2 Likes

Sure Sir, Thanks for your time.

Hi @Noor_jamali,

I believe you contacted me on LinkedIn as well, asking for help and I asked you to join our Community so that our mentors could help you.

Firstly, welcome!

Secondly, other learners and mentors cannot help you if you ask general questions like @paulinpaloalto mentioned. You have to let us know what is exactly the issue you are facing, what error you are getting so that others would know how to help you.

Thanks,
Mubsi

1 Like

If you have trouble understanding, let me know and we can talk in Urdu.

2 Likes

Sir, I think I am having an issue with Python concepts. It’s like a lot of functions are in demand in that assignment, so that’s why I am stuck and not able to complete it.

Yes, Sir, I reached out to you via LinkedIn, and it is because of your kindness that you remembered me and offered your help.

1 Like

Hi @Noor_jamali,

Do you have any programming experience with any other language ?

1 Like

Yes sir. Previously, I learned C++, Java, and Python in my course of Digital Image Processing, and currently, I am learning Flutter for Android and iOS development.

That’s good. So you know how to think logically in terms of writing programming code. I’d recommend, think of the logic and then search on google how to do it in Python. Additionally, for open source material, you can get great help from Youtube. You can find many crash courses on python, or you can specifically search for things you want to know, especially, how to do something using another library such as numpy or pandas.

2 Likes

That’s somewhat more specific, but still not very specific. So Mubsi has given you the best advice he can given that question: think about what you need to do from an algorithm standpoint and then google how to do that in python.

But the best way to get help is to ask a really specific question. As in, I tried to implement this function (name the function in the exercise) and the test fails and throws an exception or I got a syntax error and here is the error output I am getting. It’s fine to “copy/paste” in a full exception trace or the output of one of the test cells. Just note that we’re not supposed to publish and share our solutions, even if they aren’t complete yet. If the mentors can’t figure out how to give advice without actually seeing your code, we will contact you privately by DM so that we can make progress while still obeying the “no public sharing of solutions” rules.

Online courses are not the same as the traditional F2F (Face to Face) education model where you can go to Office Hours and talk to a TA in person. The Discourse forum is the best we can do, but it actually works pretty well once you get the feel for how to use it effectively. Another way to get familiar with that is just to browse some of the existing threads and see how past conversations have played out.

Regards,
Paul

2 Likes

Okay, Sir, thanks for your guidance, and I have noted everything you mentioned. Soon I will post a more specific question.

Thank you so much for your guidance, Sir. I will try to practice more with Python and will post a more specific question soon.

I am unable to understand why I am getting this error when the syntax is correct. Kindly provide a solution.
{moderator edit - solution code removed}
pp3

The problem is that the parentheses do not match on the previous line of code: there are 6 open parens, but only 2 close parens. The way the python interpreter works is that it keeps looking forward onto the next line hoping to find more close parens and then throws the error when it sees something that conflicts with that.

The editor in the notebook is “syntax aware”, so you can click on a paren or bracket and it will highlight the matching one. Or not … :scream_cat:

BTW as I mentioned earlier, we aren’t supposed to just share our solution code publicly here. If you had just posted the error message, I could have given you the same answer without actually seeing your code.

So the “meta” lesson here is that if you get a syntax error and can’t figure it out, that most likely means you are looking in the wrong place. :grin: There is nothing wrong with the line that throws the error, but the problem is caused by something incomplete that came before …

Sorry, I am a bit unclear about the relationship between check_for_leakage_test and check_for_leakage?

Do we need to insert a new cell for check_for_leakage_test to compute the expected output for Test Cases 1 and 2?

Hi @Mohammed_Othman,

check_for_leakage is the function you are supposed to implement. check_for_leakage_test is the function written by us that will verify your implementation for the function check_for_leakage. You are not supposed to change/add/delete anything in the cell where the test case function are, like in this case, check_for_leakage_test.

Hope this clarifies,
Mubsi

Exactly as Mubsi says, you do not need to do anything to change the test cell. For every function you need to complete, there is a corresponding test cell. Typically the very next cell below the function cell. Also note that if you are curious you can examine the test functions to see how they work: just click “File → Open” and have a look around at the other files associated with the notebook. You can figure out the name of the file by examining the “import” cell early in the notebook. Typically the top level test functions are in a file called public_tests.py, but sometimes they also call other utility functions in different python files. It can sometimes be useful to see the test data that they are using to help you understand where your code is going wrong. The one caveat is that these test functions use some pretty advanced python techniques, like passing a reference to a function as a parameter to another function. Of course the positive spin on that is that you might just expand your python knowledge by looking at them. :thinking:

One other general point to make is that the tests in the notebook can be thought of as “unit tests” for your individual functions. Sometimes the test data that they use is simpler than the “real” input data that will eventually be used, but they are just trying to confirm the correctness of your code. Also note that SQA (which is what we are doing here) is difficult: writing tests that catch all possible mistakes is not a simple matter. So keep in mind that even if you pass the tests in the notebook, you can still fail the grader. One type of bug that can cause that is “hard-coding” some of the assumptions in your code to match the specific test data for that function in the notebook (e.g. the sizes and shapes of the inputs or by referencing global variables instead of the parameters passed in). So the mathematical statement is that passing the tests in the notebook is a necessary, but not sufficient, condition to also pass the grader. :nerd_face:

2 Likes

@paulinpaloalto, your replies here are pure gold!