Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A few well-placed examples
k-NN keeps every training point. Nearest centroid keeps only one average per class, which fails when a class has several distinct forms. LVQ keeps a handful of “prototype” examples per class and learns where to put them: each training example pulls its nearest prototype closer if they share a class, and pushes it away if they don’t. The prototypes migrate to the spots that best mark out each class, including several separate spots for a class with several faces.
On-board classifiers must be small and fast. LVQ compresses hundreds or thousands of labelled events into a few prototypes that are cheap to store, fast to compare, and readable: each prototype is a typical event of its class, and an engineer can inspect it. It also handles classes with several operating regimes.
- 1. LVQ classifies a point by…
- 2. During training, a prototype of the wrong class is…
- 3. In the demo, 1 prototype per class on XOR data gives about…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.One LVQ1 step by hand
The prototypes are p₀ = (0, 0) (class 0) and p₁ = (4, 0) (class 1). The learning rate is α = 0.5.
- Example x = (1, 0), class 0. The nearest prototype is p₀ (distance 1), with the same class, so pull: p₀ ← p₀ + 0.5(x − p₀) = (0.5, 0).
- Example x = (1, 0), class 1. The nearest prototype is still p₀, but the classes differ, so push: p₀ ← p₀ − 0.5(x − p₀) = (−0.5, 0).
p₁ is not touched in either case. Only the winner moves.
LVQ2.1 updates the two nearest prototypes when one has the right class and the other the wrong one, and only if the example lies near the midway boundary between them (a “window”). With window w = 0.2, the ratio of the two distances must exceed (1 − w)/(1 + w) = 0.667.
The steps in plain English:
- Choose m prototypes per class and initialise them at spread-out training points of that class.
- Loop over shuffled training examples; find the nearest prototype.
- Same class: move it toward the example. Different class: move it away. Use a decreasing step size.
- Optionally fine-tune with a few epochs of LVQ2.1, using a small step: it is unstable with large ones.
- Classify new points by their nearest prototype.
- 1. p₀ after pulling toward (1, 0) with α = 0.5?
- 2. LVQ1 moves how many prototypes per example?
- 3. LVQ2.1's window threshold for w = 0.2?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.The algorithms
LVQ1 (Kohonen, 1988). For a sample (x, y) with nearest prototype p_j of label c_j: p_j ← p_j + α(t)(x − p_j) if c_j = y, and p_j ← p_j − α(t)(x − p_j) otherwise. The rate α(t) decays, for example linearly from 0.3 to 0.
LVQ2.1. Let p_j and p_k be the two nearest prototypes, one correct and one wrong. If min(d_j/d_k, d_k/d_j) > (1 − w)/(1 + w), attract the correct one and repel the wrong one. This sharpens the boundary but can diverge: prototypes that keep being repelled drift away (exercise 1). Use small steps and few epochs, or LVQ3, which adds a stabilising term.
Generalised LVQ (GLVQ) (Sato and Yamada, 1996) minimises a smooth cost Σ f(μ), with relative distance difference μ = (d⁺ − d⁻)/(d⁺ + d⁻), by gradient descent. This makes LVQ a margin-based method with convergence guarantees.
Relevance LVQ (GRLVQ, GMLVQ) also learns feature weights or a full metric.
Initialisation matters. Random picks can place two prototypes in the same cluster, so seed them spread out (k-means++ style within each class) or with class-wise k-means.
# scikit-learn has no LVQ; the 'sklvq' package implements GLVQ / GMLVQ:
# from sklvq import GMLVQ; GMLVQ(prototype_n_per_class=3).fit(X, y)
# A simple baseline: per-class k-means centroids as prototypes, then 1-NN on the prototypes.Use it when you need a compact, interpretable, fast classifier for classes with a few clusters each, for example for embedded or on-board deployment. Prefer k-NN when memory is no issue, and SVMs or boosting for maximal accuracy.
- 1. GLVQ improves LVQ by…
- 2. LVQ2.1 can diverge because…
- 3. GMLVQ additionally learns…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory and relatives
What LVQ optimises. LVQ1 is a heuristic. It roughly approximates minimising misclassification, by pulling prototypes into class-dense regions and away from other classes. GLVQ makes this precise. Its cost uses the relative distance difference μ ∈ [−1, 1], which is negative when x is correctly classified, so it is a hypothesis margin. Margin-based generalisation bounds follow (Crammer et al., 2002).
Spectrum of prototype methods:
- 1 prototype per class is nearest centroid (high bias);
- n prototypes is 1-NN (high variance, large memory);
- LVQ chooses m prototypes per class in between, tuned by cross-validation.
In exercise 2, 6 prototypes per class matched 5-NN’s accuracy while storing 33 times fewer vectors.
Relatives:
- vector quantisation and k-means, unsupervised (D8);
- self-organising maps (Kohonen), which add a topological neighbourhood;
- prototypical networks and other few-shot learners in embedding spaces (E15);
- RBF networks, whose centres are often initialised by LVQ or k-means.
Interview questions.
- Why can’t LVQ fix a too-small codebook? With 1 prototype for a 3-cluster class, the prototype is pulled in three directions and pushed by neighbours of other classes. It ends somewhere unhelpful, sometimes worse than the plain mean (exercise 2: 0.47 against 0.68).
- How do you choose m? By cross-validation, or from domain knowledge of operating regimes.
- 1. LVQ with n prototypes (one per training point, not moved) is…
- 2. GLVQ's relative distance difference is negative when…
- 3. Self-organising maps add…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Faults with several operating regimes
History.
- Kohonen introduced LVQ (1986–1990) alongside self-organising maps, for speech recognition (the “phonetic typewriter”).
- LVQ2.1 and LVQ3 (1990) refined the boundary updates.
- Sato and Yamada (1996) introduced GLVQ.
- Hammer and Villmann (2002) introduced relevance learning (GRLVQ).
- Schneider, Biehl and Hammer (2009) introduced matrix learning (GMLVQ).
- LVQ variants remain popular in biomedical and industrial diagnostics for their interpretability.
Exercise 1. On XOR-like data (each class in two opposite corners), nearest centroid scores 0.502, at chance. LVQ1 with 2 prototypes per class reaches 0.983, and LVQ2.1 fine-tuning keeps 0.981. LVQ2.1 with step 0.05 for 10 epochs diverges: prototypes reach |x| = 21, far outside the data.
Exercise 2: faults in 3 operating regimes each. Setup: 3 fault types, each a 3-cluster class in 4-D telemetry; 600 training events; 3 repetitions.
| Model | Accuracy | Stored vectors |
|---|---|---|
| Nearest centroid | 0.684 | 3 |
| LVQ1, 1 per class | 0.473 | 3 |
| LVQ1, 3 per class | 0.979 | 9 |
| LVQ1, 6 per class | 0.987 | 18 |
| 1-NN | 0.981 | 600 |
| 5-NN | 0.986 | 600 |
- One prototype per class cannot describe a 3-regime class. Nearest centroid reaches only 0.68, and LVQ with one prototype is even worse (0.47): the repulsion drives the lone prototype to a poor compromise.
- Matching the codebook to the regimes (3 per class) jumps to 0.98.
- 6 prototypes per class equal 5-NN’s accuracy with 33 times fewer stored vectors. For on-board use, that means 33 times less memory and faster prediction.
LVQ in AI, robotics and aerospace
- Embedded fault classifiers: a few interpretable prototype events per fault.
- Condition monitoring: prototypes for each machine state and regime.
- Speech and signal recognition: the original LVQ application.
- Few-shot and prototype networks: learned prototypes in embedding spaces.
References
- T. Kohonen (1990). “Improved versions of learning vector quantization.” IJCNN.
- T. Kohonen (2001). Self-Organizing Maps, 3rd ed. Springer.
- A. Sato, K. Yamada (1996). “Generalized learning vector quantization.” NeurIPS.
- P. Schneider, M. Biehl, B. Hammer (2009). “Adaptive relevance matrices in learning vector quantization.” Neural Computation 21(12).
- K. Crammer, R. Gilad-Bachrach, A. Navot, N. Tishby (2002). “Margin analysis of the LVQ algorithm.” NeurIPS.