AssertionError: Wrong value for dj_db. Expected: 0.28936094 got: 0.3468239951240354

UNQ_C3

GRADED FUNCTION: compute_gradient

I’m getting this Error
I have tried to debug it on my own, but not able to figure out

The value I’m getting very near to the expected value, there is a minor error
Help needed

Thanks in Advance

Hey @Sambari_Manikanta,
The error that you are getting is not a minor error. If we calculate a rough percentage for the error, it will be approximately 19.72%. Please go through your implementation once and make sure that your indentation is correct, and your code indeed calculates the values as per the formulation. If you are still unable to figure out the issue, please DM your code for the function to me.

Cheers,
Elemento

Hey @Sambari_Manikanta,
In general, you can make your code as modular as you want to. In-fact, a modular code is considered as a good practice. However, in these graded assignments, I am not sure if the auto-grader will allow you to make extra functions than the ones given, to out-source your code. So, it would be better to restrict all your code in the given functions only, just to ensure that the auto-grader will assess your code properly.

Also, I can see an error in your code. When you are computing f_wb in the compute_gradient function, you are using the custom compute_f_wb function. However, as per the implementation of the compute_gradient function, f_wb is supposed to be calculated for a single example, i.e., it needs to be calculated on the basis of X[i] and you are using X. In simple words, even if you want to write your code like this, you would need to correct your implementation of the compute_f_wb function. I hope this helps.

Cheers,
Elemento