## 4 Machine Learning to Identify Bat Calls
### Design of the Neural Network Algorithm to Classify the Bat Calls  
Several machine learning algorithms were tested for a further comparison of their results and the highest performing ones were selected. Before using the machine learning algorithms, the dataset was balanced, equalizing the number of audio fragments in each of the categories. We used both basic and complex classifiers to find the algorithms that were better adapted to the problem. The basic classifiers used were Random Forest (RF) [50], the Gaussian Naive Bayes (GNB) [51], and Linear Regressors (LR) [52]. Two Neural Networks (NN) were also used: a Feedforward Neural Network (FNN) [53] and a Convolutional Neural Network (CNN) [54]. The performance results obtained demonstrate that simple algorithms achieve higher recall scores but worse precision scores. In the case studied, our concern was to ensure that the prediction outputs were correct, so the metric that we were most interested in were precision or specificity. For that reason, the Neural Networks were chosen as the algorithm to use. Figure 11: Original spectrogram matrix of a sample audio file and the extracted matrix parameterizations of each call pulse. Each highlighted pulse is associated with the corresponding extracted matrix but the purple one, which does not meet with the parameterization specifications. We have used the two different Neural Networks (NNs) that best fit each parameterization of the data. For the filter bank coefficients parameterization, a simple FeedForward Neural Network (FNN) has been used [53]. This kind of network has been elected both for its simplicity and for its good performance with speech recognition [55]. For the energy matrices parameterization, the network used has been a Convolutional Neural Network (CNN). The use of the spectrogram energy matrices gives an image processing approach to the problem and this kind of network achieves high accuracy results in automatic image classification [56]. The models have three categories of data to predict, as they have been trained with the three classes: _Pipistrellus pipistrellus_, _Pipistrellus pygmaeus_, and silence. In this stage, in the machine learning algorithms design, the train and validation takes into account three categories, there is no previous selection of bat call against silence, despite the design of the dataset has used this kind of algorithms. The FNN is composed of three dense layers, which define a fully connect each input to each output within its layer. They have a _relu_ activation defined, which transforms any negative input given to zero. It is composed of a first hidden layer with 14 nodes, a second hidden layer with seven nodes, and a final output layer used for regression. The last layer is activated by a _softmax_ function. In both classifiers, the dataset has been split into three categories, which correspond to the training (64%), the validation (16%) and the testing datasets (20%). Firstly, the training set has been used to fit the model. Each time the model was trained, a test using the validation set was performed to fine-tune its parameters, such as the number of layers that composed the network or the batch size used to train the model. Performance parameters were gathered to avoid overfitting. The final performance parameters obtained, shown in Table 1, reflect how different the silence intervals are from the bat calls, as this category is clearly differentiated from the others. On the other hand, bat calls are more likely to be mispredicted. These results coincide with the t-SNE [49] results of the already commented Figure 8.  
For the energy matrices, a CNN [54; 56] is used. This kind of network is used in computer vision to analyze images and extract their most important and unique aspects that can differentiate them from others. Although our data is not originally an image, the followed analysis procedure is the same. The model is composed of two convolutional layers, whose function is to detect patterns on the matrices received as input.