The perceptron is the simplest neural network. It consists of an input and an output (no hidden layers), and the activation function is just the Heaviside function (step function at the origin), when the bias term is included.
This is the skeleton of the class:
library(R6)Perceptron <- R6Class("Perceptron", public = list( threshold = NULL, dim = NULL, n_iter = NULL, learning_rate = NULL, w = NULL, initialize = function(threshold = 0, learning_rate = 0.25, n_iter=100, dim=2){ self$n_iter <- n_iter self$threshold <- threshold self$learning_rate <- learning_rate } , forward = function(x){ } , backward = function(t,y,x){ } } , train = function(X,t){ } } } } , predict = function(X){ X <- cbind(-1,X) #add bias preds <- ...