Index error not resolving

i am getting an index error on my code:
def hypothesis(x, theta):
return theta[0]+theta[1]x
def error(X,Y,theta):
total_error = 0
m = X.shape[0]
for i in range(m):
total_error+=(y[i]-hypothesis(x[i],theta))**2
return 0.5
total_error
def gradient(X,Y,theta):
grad = np.array([0.0,0.0])
m = X.shape[0]
for i in range(m):
grad[0]+=-1*(y[i]-hypothesis(theta,x[i]))
grad[1]+=-1*(y[i]-hypothesis(theta,x[i]))x[i]
return grad
def gradientdescent(X,Y,learning_rate,maxitr):
grad = np.array([0.0,0.0])
theta = np.array([0.0,0.0])
for i in range(maxitr):
grad = gradient(X,Y,theta)
theta[0] = theta[0]-learning_rate
grad[0]
theta[1] = theta[1]-learning_rate*grad[1]
return theta
theta = gradientdescent(X,Y,learning_rate = 0.001,maxitr = 50)
print(theta)

Hi @chirag10,
It would be really difficult for anyone to understand code here.
I suggest you to copy paste the code in coding blocks ide and share the link here.
Also, please attach a screenshot at which line index error is occuring, I will directly see that piece of code, instead of scanning all the functions.

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.