Created
January 8, 2022 10:11
-
-
Save Chiraagkv/0de16d163cc47508a3d808b5353b5f8d to your computer and use it in GitHub Desktop.
This file contains 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 gradient_descent(θ0, θ1, x, y, lr): | |
new_weights = [] | |
y_preds = θ0 + θ1 * x | |
new_weights.append(θ0 - lr * (2 / len(y)) * sum(y_preds - y)) | |
new_weights.append(θ1 - lr * sum((y_preds - y) * x)) | |
return new_weights |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment