# IoT System for Detecting the Condition of Rotating Machines Based on Acoustic Signals
## 2 Condition Detection Algorithm
### Hyperparameter Tuning  
The number of hyperparameters needed for the algorithm in Figure 3 is significant (4 different scalar values and one vector), and it is not feasible to expect the user to be able to determine the appropriate values for each machine. Therefore, some form of hyperparameter tuning algorithm needs to be developed.  
Hyperparameter tuning consists of several steps: selection of the initial hyperparameters, training NN for selected values, evaluating the performance of that NN and then repeating the procedure with slightly changed values of hyperparameters. This procedure repeats several times until satisfactory results are obtained. Generally, this procedure is conducted either by trial-and-error approach or by using the grid search optimization technique. However, due to a sheer number of hyperparameters that need to be adjusted in FASTER algorithm, these approaches are too computationally expensive and calculations can last for several hours.  
In this paper, the combination of heuristic rules and genetic algorithms is used for hyperparameter optimization. There is some flexibility in choosing hyperparameters used in the preprocessing step of the algorithm, so their value can be approximately determined without the need for mathematical optimization. For example, acoustic signatures for most rotary machines have significant frequencies somewhere between 1 Hz and 1000 Hz. Consequently, by choosing an audio signal whose length (\(L\)) is between 45 s and 60 s, the main oscillatory dynamic of the signal will be captured. The shift between two consecutive windows (\(d\)) should be small enough to create as many-windowed signals as possible, but large enough to keep the diversity of the recording and prevent overfitting. The choice between \(L/10\) and \(L/3\) is shown to be valid for all machines experimentally tested. Finally, the new sampling frequency should be several times larger than the highest significant frequency of the signal. Since most rotary machines tested within our research have the largest significant frequency of 500 Hz, the initial choice for this parameter for most industrial applications can be around \(Fs=4800\) Hz.  
Feature extraction and classification steps of the algorithm have hyperparameters that must be adjusted more rigorously because the slightest shift in these parameters can significantly affect the overall performance. For this purpose, a genetic algorithm is used [29]. This is an optimization technique that models evolutionary theory by generating a population where individuals compete for survival. Each individual in the generation is a possible solution to a given problem (a point in the search space) and is represented by a chromosome (which is usually a set of bits). The fittest individuals (ones that are most successful by the given criteria) survive longer and reproduce, thus preserving their genetic material in the following generations. This approach is shown to work well for NN hyperparameter tuning [30] and is chosen as a promising solution for the optimization of these parameters for several reasons. First, both _dwt_lvl_ and elements of _nn_layers_ are integers with narrow lower and upper bounds. Therefore, this can be described as a nonlinear constrained integer optimization problem, which is challenging for many classical optimization techniques. Furthermore, an analytic solution for this problem is not possible and there are likely many local minima, so the GA approach where the entire parameter space is searched in parallel has a larger probability of finding the global solution. Finally, the performance of the trained neural network is used as an optimization criteria function, so it is stochastic in nature. GA is shown to be superior to standard optimization techniques in all these cases. A detailed description of these steps is given in