my code is like:
def hypothesis(X,theta):
m,n=X.shape
#y_=0
y_=np.dot(X,theta)
return y_
def gradient(X,y,theta):
m,n=X.shape
y_=hypothesis(X,theta)
grad=np.dot(X.T,(y-y_))
return grad/m
def error(X,y,theta):
e=0
m,n=X.shape
y_=hypothesis(X,theta)
e=np.sum((y_-y)**2)
return e/m
def gradient_descent(X,y,learning_rate=0.1,max_steps=300):
m,n=X.shape
theta=np.zeros((n,))
error_list=[]
for i in range(max_steps):
e=error(X,y,theta)
error_list.append(e)
grad=gradient(X,y,theta)
theta=theta - learning_rate*grad
return theta,error_list
this code is continuously showing opposite values of error list. Please checks
Thanks in advance