Skip to content

Instantly share code, notes, and snippets.

@curiousily
Created March 31, 2019 12:17
Show Gist options
  • Save curiousily/a4c26881837b8b31407dd9da7079c501 to your computer and use it in GitHub Desktop.
Save curiousily/a4c26881837b8b31407dd9da7079c501 to your computer and use it in GitHub Desktop.
def fit(X, y, n_iter=100000, lr=0.001):
W = np.zeros(X.shape[1])
for i in range(n_iter):
z = np.dot(X, W)
h = sigmoid(z)
gradient = np.dot(X.T, (h - y)) / y.size
W -= lr * gradient
if(i % 10000 == 0):
e = loss(h, y)
print(f'loss: {e} \t')
return W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment