Last active
March 31, 2019 12:10
-
-
Save curiousily/9a22724d261c1271edd6fa8e4a2c7881 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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