## 3 Methodology
### Algorithmic Approach
#### 3.1.2 Variational Autoencoder  
The variational autoencoder, like other autoencoders (AEs), is composed of two parts: (i) the encoder, which performs the learning/compression of the data into a reduced dimension, called latent space, while preserving the most relevant information; and (ii) the decoder, which performs the reconstruction of the input data with the smallest possible loss [48; 49]. Figure 4 illustrates the architecture of AEs, as defined above: the encoder on the left side, the compressed information on the middle, and the decoder on the right side.  
The main characteristic of the VAE is associated with the modeling of the latent space, \(Z\), as a function of a random variable with a given type of distribution. Usually, an isotropic normal distribution is applied, because it is considered that the relations between variables in a reduced dimension will be less complex than in the input dimension.  
The architecture of the VAE used in this study is represented in Figure 5. In this context, the work of [PERSON] and [PERSON] [39] was used as a baseline for the VAE design and associated parameterization, including the number of neurons, activation functions, and layers used. The encoder (an orange element in the figure) and the decoder (green element in the figure) were both designed with a bi-directional layer of 128 Long Short-Term Memory (LSTM) cells in each direction [50; 51], making a total of 256 cells, with \(tanh\) activation function, and as result, the concatenation of the two layers. The latent space \(Z\) was modeled according to an isotropic normal distribution [52; 53], with the parameters \(\mu_{z}\) and \(\sigma_{z}\) being obtained through two fully connected artificial neural network layers, which connect to the last state (\(h_{t}\)) of the encoder, with linear activation and SoftPlus, respectively. The latent space \(Z\) is calculated using the approximation \(Z=\mu_{z}+\sigma_{z}\epsilon\), where \(\epsilon\) is a random value of the chosen distribution that acts as an auxiliary noise. The latent space vector, \(Z\), is repeated \(t\) times and then, in the decoder, data are reconstructed into the original form. The detection of anomalies with this model can be carried out based on the reconstruction error or, as it is a probabilistic model in which the parameters of a distribution are reconstructed, it is possible to use probabilistic measures for the classification of anomalies [53]. In our  
Figure 4: Sketch of the AE base architecture.  
Figure 3: Sketch of anomaly detection with IF.  
case, we opted for a more conventional solution, i.e., detection by reconstruction error and the use of a sliding window to perform the identification of potential anomalies.  
There are several recent works where the VAE algorithm has been used for unsupervised anomaly detection. The one made by [PERSON] and [PERSON] [39] stands out, where an VAE was applied to the anomaly detection on photovoltaic production data, in order to identify problems with possible causes on the weather or inverters failure, for example. In another work, [PERSON] et al. [54] proposed a model named \"Donut\", a VAE-based approach to perform unsupervised anomaly detection for seasonal KPIs in web services. The author concluded that the \"Donut\" model outperformed the state of the art at that time. Furthermore, [PERSON] et al. [42] made a comparison study of algorithms in different datasets to identify anomalies, with VAE-based feature extraction as one of the approaches.