What is wrong with my code

def hypothesis(X,theta):
y_=theta[0]+theta[1]*X
return y_

def gradient(x,y,theta):
m=x.shape[0]
grad=np.zeros((2,))
for i in range(m):
X=x[i]
y_=hypothesis(X,theta)
Y=y[i]
grad[0]+=(y_-Y)
grad[1]+=(y_-Y)*X
return grad/m

def error(x,y,theta):
m=x.shape[0]
total_error=0.0
for i in range(x):
y_=hypothesis(x[i],theta)
total_error+=(y_-y[i])**2
return total_error/m

def gradientDescent(x,y,learning_rate=0.1,max_steps=100):
error_list=[]
theta_list=[]
theta=np.zeros((2,))
for i in range(max_steps):
grad=gradient(x,y,theta)
e=error(x,y,theta)
error_list.append(e)
#update theta
theta[0]=theta[0]-learnimg_rategrade[0]
theta[1]=theta[1]-learnimg_rate
grade[1]
theta_list.append(theta[0],theta[1])
return error_list,theta_list

Hey @sankalparora5, its not feasible at our end to check your code line by line. Hope you understand that and Here is the link to the actual file, https://github.com/coding-blocks-archives/machine-learning-online-2018/blob/master/3.%20Linear%20Regression/Linear%20Regression/02_Linear_Regression.ipynb

Plz check your code line by line from here.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

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.