# Accelerometer-Based Pavement Classification for Vehicle Dynamics Analysis Using Neural Networks
## 2 Materials and Methods
### Neural Network  
Neural network and multinomial logistic regression were used to recognize the pavement type. \(D=\{(x_{i},c_{i}):1\leq i\leq n,x_{i}\in\mathbb{R}^{m},c_{i}\in S\}\), where \(S=\{s_{1},s_{2},\ldots,s_{p}\}\) denotes the set of pavement types. The sequence \(x_{i}\in\mathbb{R}^{m}\) is a signal recorded from the accelerometer. All measured parameters were captured at a frequency of 200 Hz using the dSpace Autobox system and subsequently analyzed on a computer using Matlab R2022a software. The main automotive I/O card was the DS2211 HIL 1/0 board. This allowed for the quick measurement of the required signals. The vehicle was operated at a nearly constant speed of 30 km/h throughout testing. To provide precise statistics, the vehicle was driven many times on the aforementioned road surface. To solve the classification problem, we applied the one-hot encoder \(h:S\rightarrow\{0,1\}^{p}\) to the output variable as follows:  
\[h(c_{i})=\{y_{ij}\}_{1\leq j\leq p}, \tag{1}\]  
and  
\[y_{ij}= \begin{cases}0,&c_{i}\
eq s_{j},\\ 1,&c_{i}=s_{j}.\end{cases}  \tag{2}\]  
Below, we extracted dependences between the signal obtained from accelerometer and the pavement type by analyzing the data set \(D=\{(x_{i},y_{i}):1\leq i\leq n,x_{i}\in\mathbb{R}^{m},y_{i}\in\{0,1\}^{p}\}\). \((\Omega,\mathcal{F},P)\) is the probability space and \(Y:\Omega\rightarrow\{1,2,\ldots,p\}\) is a random variable denoted by the type of pavement. The classification problem consists of the probability estimation \(P(Y=j|x)\) that the pavement has type \(j\) based on recordered signal \(x\in\mathbb{R}^{m}\) for \(j\in\{1,2,\ldots,p\}\). Neural network is one of the most used types of machine learning and is usually utilized for classification or regression analysis [37; 38; 39]. A neural network structure consists of inputs, weights (parameters), aggregation functions, activation functions, and outputs. In multilayer networks, the inputs of the first layer are the predictors from the training set. In neural networks, the aggregation function is defined as the linear combination of the inputs and weights, and the result of the aggregation function is sent to the activation function \(g_{j}\), defined as follows:  
\[Z_{j}(x)=g_{j}(w_{j}Z_{j-1}(x)+\alpha_{j}), \tag{3}\]  
where \(w_{j}\) denotes the weights, \(\alpha_{j}\) for \(j=1,2,...,K\) is the bias, and for input layer, \(Z_{0}(x)=x\). Thus, for neural networks containing \(K\)--layers, the inputs of the next layer consist from neuron, which are the values of activation function of the current layer. From (3) the last layer is defined as follows:  
\[Z_{K}(x)=g_{K}(w_{K}g_{K}(w_{K-1}Z_{K-2}(x)+\alpha_{K-1})+\alpha_{K})=\ldots \tag{4}\] \[=g_{K}(w_{k}g_{K-1}(w_{K-1}g_{K-2}(\ldots g_{2}(w_{2}g_{1}(w_{1}x +\alpha_{1})+\alpha_{2})\ldots)+\alpha_{K-1})+\alpha_{K})\]  
The three-layer neural network was utilized to analyze the road type. First, the road type as factor variable was coded (the category encoder was used). For the first layer, the softsign activation function  
\[\textit{softsign}(x)=\frac{z}{|z|{+}1}, \tag{5}\]  
was applied; for the second layer, the _relu_ activation function  
\[\textit{relu}(z)=max\{0,z\}, \tag{6}\]  
was used. For the last (output) layer, the _softmax_ activation function  
\[\textit{softsmax}(z)=\frac{1}{\sum_{j=1}^{k}e^{z_{j}}}(e^{z_{1}},e^{z_{2}}, \ldots,e^{z_{p}}), \tag{7}\]  
was applied; \(1\leq i\leq k\) and \(k\) denotes the numbers of categories of the output variable. To optimize the classification model, we used the cross-entropy as the cost function.