February 2018
Beginner to intermediate
258 pages
5h 47m
English
We can, in a very similar way, implement logistic regression as an R6 class. The code is included just for intellectual curiosity, as it is closely related.
There is not a lot of difference between the perceptron and logistic regression. They share a lot in common, the main difference being the activation function (logit instead of the Heaviside step function), which also changes the update rule for the weights. For convenience, we highlight in bold the more relevant differences:
library(R6)logit <- function(x){ 1/(1+exp(-x))}LR <- R6Class("LR", public = list( dim = NULL, n_iter = NULL, learning_rate = NULL, w = NULL, initialize = function(learning_rate = 0.25, n_iter=100, dim=2){ self$n_iter <- n_iter self$learning_rate ...Read now
Unlock full access