Last active
October 28, 2017 16:26
-
-
Save yvan/d58e474560660fa7817e9e05eeb49354 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
# performs the gradient descent for linear regression | |
def calc_regression_simple(w1, frames, x_data, y_data): | |
learn_rate = 0.001 | |
ys = [] | |
for i in range(frames): | |
# get the gradient and update the parameter | |
w1_gradient = 2*np.mean(x_data*(w1*x_data - y_data)) | |
w1 = w1 - (w1_gradient*learn_rate) | |
# calculate the predictions from this new function | |
x = np.linspace(0,30) | |
ys.append(w1 * x) | |
# returns each linear regsession y values | |
# at each step, x values don't change | |
return ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment