# Sigfox and LoRaWAN Datasets for Fingerprint Localization in Large Urban and Rural Areas
## 4 Analysis  
This section describes how our LPWAN datasets can be used for basic \(k\)NN fingerprinting localization. Of course, \(kNN\) is not the only algorithm that can be used, the implementation below merely serves as an example on how to use our datasets. Our future work includes an extensive evaluation on different fingerprinting implementations such as support vector machines, decision trees, neural networks, etc. Before localization, a dataset should be split up into three subsets: a training set, an evaluation set and a test set. In order to ensure an unbiased spatial spread across the subsets, the main dataset should be divided randomly. The training set, which should be the largest of the three subsets, serves as a reference database for the fingerprinting algorithm. Afterwards, these subsets can be used for the localization algorithm as follows. Firstly, a distance matrix between the training and evaluation sets has to be computed by calculating the Euclidean distance \(d\) between every fingerprint in the evaluation set and every fingerprint in the training set, as illustrated in Equation (1). In this equation, the RSSI measurements for the evaluation fingerprints and the training fingerprints are represented by \(RSSI_{eval}\) and \(RSSI_{training}\) respectively. \[d=\sqrt{\sum(RSSI_{eval}-RSSI_{training})^{2}} \tag{1}\]  
Every distance \(d\) is stored in a matrix with \(m\) rows and \(n\) columns, with \(m\) matching the amount of samples in the evaluation set and \(n\) the amount of samples in the training set. Secondly, this distance matrix is used to find the \(k\) Nearest Neighbors (\(k\)NN) of an evaluation fingerprint: for every row in the matrix, the column indexes of the \(k\) smallest distances \(d\) are extracted and compared to the real world locations of the corresponding row indexes of the training set. These rows in the training set are the training fingerprints which correspond best to the evaluation sample. The centroid of the locations of these \(k\) training fingerprints can be used as the location estimate for the evaluation \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**BS 1** & **BS 2** &... & **BS 68** & **RX Time** & **SF** & **HDOP** & **Latitude** & **Longitude** \\ \hline \(-101\) & \(-95\) &... & \(-200\) & 2018-01-09T23:42:19+00:00 & 9 & 0.60 & 51.19404602 & 4.41862487 \\ \(-200\) & \(-111\) &... & \(-200\) & 2018-01-31T10:01:27+00:00 & 12 & 1.08 & 51.20004272 & 4.4116702 \\... &... &... &... &... &... &... &... &... &... \\ \hline \hline \end{tabular}
\end{table} 
Table 4: The structure of the urban LoRaWAN dataset. Every row represents a LoRaWAN message and indicates its receiving base stations (BS), the receiving time of the message (RX Time), the LoRa spreading factor, and the Horizontal Dilution Of Precision (HDOP), latitude and longitude of the transmitter at transmission time. Figure 8: The urban LoRaWAN dataset holds 123,529 messages that were collected from 17 November 2017 to 5 February 2018. This figure illustrates the temporal spread of this dataset. sample. By comparing this estimate to the actual GPS coordinates of the evaluation sample, the location estimation error can be quantified. This location estimation process is repeated for every row in the distance matrix with different values for \(k\), to calculate the mean estimation error for a given \(k\) and subsequently, to find an optimal value for \(k\). Lastly, the test subset is used to validate this optimal \(k\) with fingerprints that do not occur in the training or evaluation subset. A new Euclidean distance matrix between the training subset and the test subset is created and used to calculate the mean location estimation error for the best \(k\). In the list below, the main steps of this basic fingerprinting algorithm are summarized, whereas Figure 9 displays a concise visual representation. 1. Split the dataset in subsets. E.g., 70% training, 15% evaluation and 15% test samples. 2. Calculate a Euclidean distance matrix between the training set and the evaluation set. 3.