Skip to content

Instantly share code, notes, and snippets.

@starhopp3r
Created September 26, 2017 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starhopp3r/6d2b3f7a269ed9648d6f037e90599362 to your computer and use it in GitHub Desktop.
Save starhopp3r/6d2b3f7a269ed9648d6f037e90599362 to your computer and use it in GitHub Desktop.
def run():
points = genfromtxt('data.csv', delimiter=',')
# Hyperparameter
learning_rate = 0.0001
# Initial values: y = mx + c
initial_c = 0
initial_m = 0
# Iterations
num_iterations = 1000
# Optimal values for m and c
[c, m] = gradient_descent_runner(points, initial_c, initial_m, learning_rate, num_iterations)
# Results
error = compute_error_for_points(c, m, points)
print("Optimized after {0} iterations: m = {1}, c = {2} and error = {3}".format(num_iterations, m, c, error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment