Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created October 28, 2011 03:36
Show Gist options
  • Save marcelcaraciolo/1321566 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/1321566 to your computer and use it in GitHub Desktop.
linear regression
X = data[:, 0]
y = data[:, 1]
#number of training samples
m = y.size
#Add a column of ones to X (interception data)
it = ones(shape=(m, 2))
it[:, 1] = X
#Initialize theta parameters
theta = zeros(shape=(2, 1))
#Some gradient descent settings
iterations = 1500
alpha = 0.01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment