Wrong answer for Hazard Ratio

LAB ID: zxfnndtyhmzk

I think my formula is correct but I get the following…


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

H @getjaidev ,

If you can send me the code via DM I can take a look and provide some guidance.


Hi @getjaidev ,

If we go back to the original error, you’ll see that 2 tests are passing and one is failing. This leads me to think that the way some of the functions were coded may have issues.

Your error is caught in the hazard_ratio function. When this function is tested, the lab calls a previously defined function called to_one_hot.

Your possible error is in the to_one_hot function. In the instructions of this function, the lab requests that you drop the first dummy for each category from the dataframe.

The instructions also ask you to use the pandas’ get_dummies function to get the dataframe with categorical columns encoded as binary variables. The ‘trick’ here is in dropping the dummy for each each category to avoid convergence issues when fitting the proportional hazards model.

Please read in detail the instructions on how to use the get_dummies function, here:


You’ll find the way to drop the dummies for each categories there.

Please review these items and let me know how it goes.