Skip to contents

The nearest prototype is pulled toward a training point when their labels agree and pushed away when they do not. That repulsion is the whole difference from k-means-per-class: it drives prototypes OUT of the contested region, so where classes overlap the fitted prototypes end up further apart than the class centroids. They are placed to win the nearest-prototype vote, not to summarise their class.

Usage

morie_esl_prototype_lvq(
  X,
  y,
  n_prototypes = 2,
  eta = 0.1,
  n_epochs = 50L,
  newdata = NULL,
  seed = 0L
)

Arguments

X

Predictors, n by p.

y

Class labels.

n_prototypes

Prototypes per class.

eta

Initial learning rate in (0, 1].

n_epochs

Passes over the data.

newdata

Points to classify; defaults to X.

seed

Seed.

Value

List with prototypes, prototype_class, class, accuracy.

Details

LVQ is defined by an algorithm rather than an objective, so nothing is guaranteed to decrease; the learning rate is decayed to zero to force the iteration to settle.

References

Kohonen, T. (1989). Self-Organization and Associative Memory (3rd ed.). Springer.

Examples

set.seed(1)
X <- rbind(matrix(rnorm(200, -2), ncol = 2), matrix(rnorm(200, 2), ncol = 2))
y <- rep(0:1, each = 100)
morie_esl_prototype_lvq(X, y, n_prototypes = 2, seed = 1L)$accuracy > 0.9
#> [1] TRUE