# Integration of Directional Antennas in an RSS Fingerprinting-Based Indoor Localization System
## 4 Deployment Cycle
### Site Survey and Calibration Phase
#### 4.1.2 ANN Training  
After generating the radio map, the system requires a calibration phase to learn how to localize the tags from the captured RSS patterns. This is carried out by training the ANN integrated in the localization engine with the fingerprints (samples) gathered during the radio map generation. There are different types of ANN [25; 26; 27; 28; 29]; however, here, we have considered multilayer perceptron (MLP). Although it is not demonstrated that MLP is much superior to other approaches, such as KNN or ML methods for positioning [26], one advantage of this machine is its fast response, once it has been trained in its training phase, as will be seen below. This property allows one to have a reduced system latency and, hence, process more estimations in less time. On the contrary, methods, such as KNN or ML, have to compare the input fingerprint with the whole radio map, so that computational cost exponentially rises with the size of the radio map. The MLP is well known for being a type of universal approximator [54]. Hence, it will be possible that these ANNs learn the relation between the RSS vectors and the room ID where the tag is located (the output). The architecture of the employed MLP is sketched in Figure 5. It is composed of an input layer with \(K\) neurons, as many as SRs, one hidden layer with \(P\) neurons and an output layer with \(R\) neurons, as many as defined target rooms. All output neurons integrate a sigmoid transference function, which limits the output range from zero to one. To select the estimated room, the corresponding output with the highest value will be chosen. In order to train the MLP, a training algorithm and a convergence criterion to stop the process when the goal is reached must be chosen. The training samples are the radio map fingerprints. Then, the MLP will learn to map between RSS vectors and the associated spatial locations. To do so, a supervised training algorithm will update iteratively the weights associated with each neuron, optimizing them to minimize a previously-defined cost function (usually the mean square error (MSE)). This is done until the convergence condition is met. If the radio map is sufficiently good and an appropriate architecture has been selected, the training will be correctly performed, and therefore, classification of new RSS patterns never seen before by the MLP (not presented during the training phase) should be correctly classified within the proper room. This property is called generalization, and it is what makes these mathematical tools really attractive for complex  
Figure 4: Site survey process flowchart. classification problems. There are dozens of training procedures based on different algorithms, such as the gradient-descent method, Levenberg-Marquardt (LM) or the classical backpropagation algorithm [54]. Furthermore, some stop training criteria, such as regularization or early-stopping, have been analyzed in order to avoid overfitting and improve generalization [54]. In this case, we have employed the Levenberg-Marquardt algorithm combined with the early-stopping method for its fast convergence and the good generalization results obtained [55]. The MLP architecture (_i.e._, the transference function, number of hidden layers and neurons per layer) has been estimated from a trial and error test; again, as in the site survey process, no clear guidance can be found in the literature. These parameters also depend on the number of inputs/outputs defined, although it has been observed that one hidden layer with \(P=16\) neurons will be enough for the tests performed in this work, as will be seen in the experiments' section. Furthermore, notice that for the ANN training, the fingerprints have been pre-filtered before employing them as ANN inputs. As mentioned before, each fingerprint is described by the temporal \(N\times K\) R matrix of RSS values. From this matrix, the outliers were filtered out, and missed data from out of range of the SRs was substituted by a predefined value (the sensitivity of the hardware [23; 27]).