Hello @Deepti_Prasad
I’m running into a problem with C2W4 Programming Assignment cell UNQ_C2. I see that you’ve helped other people with similar problems.
When run in the next cell the hazard ratio value from my code is: 1.5450980645082435
However, the test asserts the value should be: 15.029017732492221
I’m wondering if the data used for this test might be incorrect. I tried resetting the lab, but the problem still occurs.
The error when I run the test is like this:
1 Like
hi @Thomas_A_W
First of all thank you for creating topic.
Your UNQc2 code implementation of hazard ratio is incorrect.
you do not need to divided the two cases instead substract. Here is a screenshot from the lab which gives on how to check hazard ratio between smoker and non-smoker
So when used np.exp is correct but further instead of using individually np.dot to each case conditions, use cox_params.dot where case 1 is substracted from case 2 and don’t forget to implement at the end .T as mentioned in the above formula.
@Thomas_A_W
as per our discussion and you corrected the unqc2 codes and yet not getting the match test result is because you are using a global variable for the dataframe in unqc1 cell to do one hot labelling. remember the argument here is presenting dataframe as dataframe compared to the global variable recalling it as df which you have used, resulting in different test results for unqc2
Yes, that was the problem. Thank you.
1 Like