Skip to content

Instantly share code, notes, and snippets.

@Chiraagkv
Created January 8, 2022 10:11
Show Gist options
  • Save Chiraagkv/0de16d163cc47508a3d808b5353b5f8d to your computer and use it in GitHub Desktop.
Save Chiraagkv/0de16d163cc47508a3d808b5353b5f8d to your computer and use it in GitHub Desktop.
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