I have used the vector approach to the question can someone please check where it is wrong it is giving 95% accuracy .
def sigmoid(z):
return 1.0/(1.0 + np.exp(-1.0*z))
def hypo(X,theta):
return sigmoid(np.dot(X,theta))
def grad(X,Y,theta):
m = X.shape[0]
hy = hypo(X,theta)
gradd = -1.0 * (np.dot(X.T,(Y - hy)))
return gradd/m
def grad_des(X,Y,lr=0.1,max=500):
m,n = X.shape
theta = np.zeros((n,))
for i in range(max):
gradd = grad(X,Y,theta)
theta = theta + (lr*gradd)
return theta