
Perceptron learning rule (Geron Ch 10, morie.fn hmpcpt)
Source:R/geron_ml2_native.R
morie_geron_perceptron.Rdw <- w + eta (y - y_hat) x with a step activation, run row by row
in index order for at most n_iter epochs, stopping the moment an
epoch makes no mistake. Converges iff the classes are linearly
separable, which is why XOR never converges.
Value
List with w, weights, bias, predictions,
accuracy, mistakes_per_epoch, converged, estimate, n.
Examples
morie_geron_perceptron(matrix(c(2, 1, 3, 2, -1, -2, -2, -1),
nrow = 4, byrow = TRUE), c(1, 1, 0, 0), eta = 0.5, n_iter = 20)
#> $w
#> [1] 0.5 1.0
#>
#> $weights
#> [1] 0.5 1.0
#>
#> $bias
#> [1] -0.5
#>
#> $predictions
#> [1] 1 1 0 0
#>
#> $accuracy
#> [1] 1
#>
#> $mistakes_per_epoch
#> [1] 1 0
#>
#> $converged
#> [1] TRUE
#>
#> $estimate
#> [1] 0.5 1.0
#>
#> $n
#> [1] 4
#>
#> $method
#> [1] "Perceptron rule w <- w + eta (y - y_hat) x with a step activation"
#>