Last active
February 13, 2020 15:44
-
-
Save dtellogaete/7a34c021f15f78cf0ff7cc34aa368602 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
# Función de Descenso de Gradiente | |
LinearRegressionGD = function(lrate = 0.1, niter = 10000, | |
X, y, theta){ | |
const = lrate*(1/length(X)) | |
for(i in 1:niter){ | |
h = X*theta[2]+theta[1] | |
theta[1] = theta[1]-const*(sum(h-y)) | |
theta[2] = theta[2]-const*(sum(h-y))*X | |
} | |
return(theta) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment