Skip to content

Instantly share code, notes, and snippets.

@curiousily
Last active March 31, 2019 12:10
Show Gist options
  • Save curiousily/9a22724d261c1271edd6fa8e4a2c7881 to your computer and use it in GitHub Desktop.
Save curiousily/9a22724d261c1271edd6fa8e4a2c7881 to your computer and use it in GitHub Desktop.
def fit(X, y, n_iter=100000, lr=0.01):
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