## 4 Self-Organizing Maps Applied to Driving-Behavior Classification
### Training Self-Organizing Maps  
First, an initial weight is assigned to each neuron connection. There are simple initialization approaches, such as using random numbers or using input samples randomly selected from the dataset. Although sophisticated algorithms that are based on data analysis (e.g., principal component analysis (PCA)) can also be used, it was observed that random initialization performed rather well for non-linear datasets [57]. Thus, in each training step, one input sample \(\mathbf{x}^{k}=(x_{1}^{k},x_{2}^{k},\cdots,x_{N}^{k})\), \(1\leq k\leq K\), from the dataset is chosen randomly, and the distances between this sample and all of the neuron weights of the SOM are computed. The most popular distance measure in real applications is the Euclidean distance \(\left\|\cdot\right\|\). \[\left\|\mathbf{x}^{k}-\mathbf{m}_{i}\right\|^{2}=\sum_{j=1}^{N}(\mathbf{x}_{j} ^{k}-\mathbf{m}_{ij})^{2}. \tag{2}\]  
The output neuron whose weight vector is closest to the \(k\)-th input sample, according to Equation (2), is the best matching unit (BMU) or the winner neuron, which is usually denoted by \(c\). \[\left\|\mathbf{x}^{k}-\mathbf{m}_{c}^{k}\right\|=\underset{i}{min}\left\| \mathbf{x}^{k}-\mathbf{m}_{i}\right\|. \tag{3}\]  
Figure 6: Typical SOM topologies: a rectangular output grid (**a**) and a hexagonal output grid (**b**). Figure 7: Structure of an SOM with \(N\) inputs, \(\mathbf{x}=(x_{1},x_{2},\cdots,x_{N})\), and \(M=25\) output neurons distributed into a \(5\times 5\) two-dimensional hexagonal grid. The BMU is used to update the weight vectors of the SOM. In this process, the BMU and its neighbors are moved towards the \(k\)-th input sample, bringing them closer. For each neuron of the SOM, the weight vector is updated, as follows:  
\[\mathbf{m}_{i}(n+1)=\mathbf{m}_{i}(n)+\alpha(n)h_{ci}(n)\left\|\mathbf{x}^{k}(n )-\mathbf{m}_{i}(n)\right\| \tag{4}\]  
where \(n\) denotes the iteration step, \(\mathbf{x}^{k}(n)\) is an input sample randomly selected from the training dataset at iteration \(n\), \(h_{ci}(n)\) is a neighborhood function or kernel around the BMU, and \(\alpha(n)\) is the learning rate. Both \(\alpha(n)\) and \(h_{ci}(n)\) are decreasing functions approaching zero with each iteration in order to guarantee the convergence and stability of the training process. The neighborhood function specifies how much the \(i\)-th neuron has to move toward the input sample at iteration step \(n\). It is a radial basis function, usually a Gaussian function that is centered at the BMU:  
\[h_{ci}(n)=exp\left(-\frac{\left\|\mathbf{m}_{c}(n)-\mathbf{m}_{i}(n)\right\|^ {2}}{2\sigma^{2}(n)}\right). \tag{5}\]  
Equation (5) defines the region of influence of the current input sample, with \(\sigma^{2}(n)\) being the neighborhood radius. Concerning the learning rate in Equation (4), different functions have been proposed, such as linear or exponential functions. In this work, a decaying exponential, with initial learning rate \(\alpha_{0}\), has been selected:  
\[\alpha(n)=\alpha_{0}e^{\left(-\frac{n}{\tau}\right)} \tag{6}\]  
where \(T\) is the number of iterations or training length. It is worth noting that Equation (4) is also suitable for the online training of SOM by substituting \(n\) by \(t\) (i.e., discrete time). In sum, the sequential training of SOMs involves the following steps:  
1. initialization. Initial weights are randomly selected from the dataset. 2. Competition. For a randomly selected input sample, all of the neurons in the output layer compete with each other to be the BMU (Equation (3)). The neuron that is closer to the input sample is the winner. 3. Cooperation. The BMU also excites the neurons in its topological neighborhood. This cooperative process decays as neurons are further away from the winning neuron (Equation (5)). 4. Adaptation. The BMU and its neighboring neurons are pulled closer to the input sample. For each neuron in the SOM, the weight vector is updated according to Equation (4).