Error In Chemical Classifier Challenge

I am having error in my code . Pls check

Hey @sanchit123manchanda, please upload your code on google drive and share the link here of the .ipynb file. Only then will I be able to debug.

Hey @sanchit123manchanda, there is error in the get_grads( ) function. Please make sure, that the gradients you are calculating are correct .

Hope this helps you :slight_smile:

i have tried making changes to it but still getting errors. Can you plss tell me the correction

You don’t have to take the transpose of y_true[i] in grad_w. Try this once.

I have tried that but still getting error.

https://colab.research.google.com/drive/1iJA6IHoZjyRSN3UOvxqdvG4Ygorcwzdc?usp=sharing

So I found 2-3 errors more, please see the following :

As far as I can see , you should replace

W = 2*np.random.random((X_train.shape[1],1))

by

W = 2*np.random.random((X_train.shape[1],))

Then why have you used a for loop when updating the values of w and b ?? Kindly remove this line :

 for i in range(1000): 

And also first you need to run gradient_descent function for some number of iterations to get the optimal values of w and b, and then you should use those values to make predictions.
Predict function should be called on testing data and gradient descent to be used with training data.

Hope this helps resolve the error :slight_smile:

Thanks a lot.
But, can you explain why did we need the shape of W to be (X_train.shape[1],) . What difference does it make ?

1 Like

Because in the hypothesis function you can see we are taking the dot product of x and w, and hence shape of w cannot be (3,1).

Please mark the doubt resolved and give feedback too.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

If you want to improve the platform then pls add more questions for practice. There are no questions of numpy,pandas and matplotlib to practice.

Sure. I will post your concern to our team.

Thank you :slight_smile: