Course 2, Week 4, Exercise 2 Error

Hi,

I am getting the error below with my code when I am running it. But I can’t seem to find the issue with my code, it looks correct for me, I did the same as what the hint said AND the formula is the same as the hazard ratio mentionned in the instruction. Can anyone can help me with this?

1.5450980645082435

Error: Wrong output. One possible solution: make sure i = 1 and j = 5
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
6
7 # DO NOT modify anything below
----> 8 hazard_ratio_test(hazard_ratio, i, j, one_hot_train, cph)

~/work/W4A1/public_tests.py in hazard_ratio_test(target, i, j, one_hot_train, cph)
88 ]
89
—> 90 multiple_test(test_cases, target)
91
92

~/work/W4A1/test_utils.py in multiple_test(test_cases, target)
121 print(‘\033[92m’, success," Tests passed")
122 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
→ 123 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for hazard_ratio. Check your equations and avoid using global variables inside the function.

1 Like

your error is pointing instead of using assigned call arguments/local variables for grade function cell you are using a general variable.

I see, I found my issue and it got resolved. Thank you!

2 Likes

that I cannot confirm as I cannot access your lab environment, but how much you shared my test cell is same.

Yes correct the arguments use by is perfectly correct but remember the test cell of hazard ratio is also using one_hot_train function which is from the previous grade cell.

So things to check would be did you use dataframe arguments to the get.dummies( ) to get one_hot_df. If yes, next check point is in hazard ratio, make sure your code is not hard coded.

The target.name is transpose tuple value of case 1 and case 2 which inturn is tuple value of the cox_params.dot to which numpy.exp need to be used to calculates the exponential of all elements in the input array.

Regards
DP