Skip to main content
. 2022 Jul 29;22(15):5681. doi: 10.3390/s22155681
Algorithm 1 Learning Vector Quantization
Input: Sample set M=(x1,y1),(x2,y2),,(xm,ym); Suppose that, q is the number of prototype vectors, t1,t2,,tq is the initial category of each prototype vector, and η(0,1) is the learning rate.
Ouput: prototype vector v1,v2,,vq
1: Initialize the prototype vector v1,v2,,vq.
2: Loop
3:  Select samples (xj,yj) from sample set M randomly.
4:  Calculate the distance between xj and vi(1iq): dji=xivi2
5:  Find the prototype vector vi closest to xj, i*=argmini{1,2,,q}dji
6: If yi=ti
7:     v=vi+η(xjvi)
8: Else
9:     v=viη(xjvi)
10: End if
11:    Update vi to v
12: Until the stop criterian is reached