Skip to content

Instantly share code, notes, and snippets.

@dirmeier
Created November 29, 2017 12:06
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 dirmeier/5fb07da88ff591e871183f1fdb157b42 to your computer and use it in GitHub Desktop.
Save dirmeier/5fb07da88ff591e871183f1fdb157b42 to your computer and use it in GitHub Desktop.
sig <- function(b, x) 1 / (1 + exp(-b * x))
loss <- function(y, b, x) (y - (sig(b, x)) %*% x
bold <- b <- 1
repeat
{
bold <- b
b <- b - loss(y, b, x)[1]
if (abs(b - bold) < 0.000001) break
}
print(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment