Hi, I spent a while debugging but have issue. I pass first test but fail 2 following tests: wrong data type and wrong value. But when I print the output arr_by_risk_group, it comes out exactly as expected.
and this is with arr_by_risk_group printed:
so what is wrong???
Hi, Dennis.
You’ve got quite a bit of experience with this scenario by now, right? You pass some tests, but not all of them. I’m not familiar with any of the AI4M courses or assignment, but notice that there’s a “None” that shows up right after the correct output for arr_by_risk_group
. What’s up with that?
The other thing to do is to look at the test cases to understand what the second and third tests are checking. Maybe add some more instrumentation based on what you learn about those failing tests.
1 Like
Hi @Dennis_Sinitsky
Your baseline risk for are by risk group is correctly matching, but if you notice the error is more related to data type mismatch but you final output you have matching result.
So I suspect somewhere in between code recalls you have used incorrect data recall,
I am suspecting for the below code
Store the baseline risk, risk_groups, and y into the new dataframe
Another hint would the instruction given before the grader cell
or example, df.groupby(‘col1’)[‘col2’].sum() groups by column 1, and then calculates the sum of column 2 for each group.
notice one column is needs round bracket and another square bracket, I hope you have followed the same .
so I had to
For treatment patients, group them by risk group, select their outcome ‘y’, and take the mean
I would use df_treatment.groupby(‘risk_group’)[‘y’].mean()
another debugging checkpoint would be
Set the index of the arr_by_risk_group dataframe to the average baseline risk of each risk group
Use data for all patients to calculate the average baseline risk, grouped by risk group.
Probably if you can DM the codes for this particular grade cell, I can check
here I would recall arr_by_risk_group.index= df.groupby(‘risk_group’)[‘baseline_risk’].mean()
Let me know if all of these are correctly followed. You can DM me your codes.
Regards
DP
Yes as Paul says you have got to start doing some debugging, you have to learn to solve problems by yourself!
When I was taking these specializations and I did almost all of them, the main ones. I was really confused and couldn’t find the issue only 2 times. The first one a post from Paul in the coursera mentor page (back then) helped me and the second one I posted for help but I solved the issue by myself an hour later. But of course I had to do many times debugging!
Hi @Dennis_Sinitsky
as you using a global variable recall from previous grader cell ‘TRTMT’ as variable for data frame baselines and treatment, you are getting this error. Remember there is difference between ‘TRTMT’ and TRTMT !!!
Another correction would be required you do not need apply any astype.float64 to
Calculate the absolute risk reduction by risk group (baseline minus treatment)
Just you normal operator without any tuple for this.
Same goes for the next code line, do not use astype.float64 for arr_by_risk_group.index
Also you have done an editing in the grader cell as you only need to write the codes between ###START AND END CODE HERE ###
But You added the below code line inside this ###START AND END CODE HERE## after the arr_by_risk_group.index
Set the name of the Series to ‘ARR’
arr_by_risk_group.name = ‘ARR’
remember these assignments are autograded, any editing can cause failure of grade especially related to this section.
Regards
DP
I debugged. I accidentally erased this line:
return arr_by_risk_group
No wonder it did not work. It would have been a miracle if it did work! 
2 Likes
Ah, ok, so maybe it was that “None” there that was the symptom of Doom. 
1 Like
It absolutely was! I just had print statements from prevous subroutine called in this function which I forgot to clean up (for model print) and it printed extra junk that threw me off. After I cleaned those prints up, it all became obvious.
1 Like
For this reason only I never add all the print statement together, rather check in stepwise and remove them if the output match, there by preventing such mistakes.
1 Like