C3_W1_Assignment_Exercise 6 - lr_ARR_quantile

Hello,

Cannot understand what’s wrong with the code. Ive tried everything.
Any recommendation?

baseline_risk
0.180227 0.030075
0.192610 0.153209
0.209209 -0.008114
0.223456 -0.148148
0.240209 0.060429
0.261270 0.037037
0.301718 0.120000
0.398248 0.060952
0.473780 0.087121
0.659986 0.077586
Name: ARR, dtype: float64

Error: Wrong output.
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in ()
1 ### test cell ex6: you cannot edit this cell
----> 2 lr_ARR_quantile_test(lr_ARR_quantile, X_dev, y_dev, lr)

~/work/W1A1/public_tests.py in lr_ARR_quantile_test(target, X_dev, y_dev, lr)
266 }
267 ]
→ 268 multiple_test(test_cases, target)
269
270

~/work/W1A1/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 lr_ARR_quantile. Check your equations and avoid using global variables inside the function.

Expected Output:
baseline_risk
0.231595 0.089744
0.314713 0.042857
0.386342 -0.014604
0.458883 0.122222
0.530568 0.142857
0.626937 -0.104072
0.693404 0.150000
0.777353 0.293706
0.836617 0.083333
0.918884 0.200000
Name: ARR, dtype: float64
All tests passed.

please do not post grade function codes, it is violation of code of conduct. refer faq section community guidelines.

and how i am supposed to find a solution?

by only posting the error you got, and if mentor want to look at your codes they will ask you to send by personal DM

alright, so apart from this, any idea about fixing my code?

can you DM me screenshot of the codes. click on my name and then message.

It seems your implementation its most probably not quite right!

How about this feedback?

@chrysa

can you confirm once if you have passed all the test before exercise 6? especially from exercise 3 and 4. Please share screenshot of those two grade functions too by personal DM. I will go through all 3 grade functions and reply back.

regards
DP

Issues with your exercise 6

  1. for code line
    Calculate the baseline risks (use the function that you just implemented)
    The hint in bracket mentions you to use the function you just implemented i.e. from exercise 5, you have used lr_predict.proba function which you were not suppose to use here. You require to use the def function name of exercise 5 for baseline risks to the dataframe.copy using the deep=True method to logistic regression model(use the assigned loca argument in the exercise 5)

  2. next code line, I suppose it might be mistype, because you use pd.qcut as the instructions below the exercise 5 header mention you to use pd.cut. Also you do not require to use label as well as duplicate argument here.

  3. next for code lines select the subset of who did receive and did not recieve treatment requires you to dataftame function to the TRTMT and mention the false and true method based on the condition and also don’t forget to specify the its position with : to the df.loc method.

  4. Also when you calculating the true outcome, mention y as [y] is create string list, so kindly use only y.mean

  5. For code line
    Set the index of the arr_by_risk_group dataframe to the average baseline risk of each risk group
    You actually complicated the codes. You just had to use the df.groupby function to the risk group and to the baseline_risk.mean. I suppose the instruction set the index confused you here. also remember baseline_risk here is not a string list as I mentioned earlier.
    You didn’t required to take separate arr_by_risk_group for baseline risk. you basically hard coded the path here.

You codes for exercise 3 and 4 are perfectly fine, and reason I wanted to see exercise 6 code was I noticed you are implementing the treatment condition state differently, so just wanted to confirm it as per autograder.

Remember your codes are incorrect but not as per the autograder, see your error log which mentions you have globa variables instead of local variables.

Regards
DP