# Mobility Classification of LoRaWAN Nodes Using Machine Learning at Network Level
## 4 Experimental Setup  
In this section, we apply the method described above to a real LoRaWAN network deployment, whose node distribution is reported in Table 2. In particular, we started our analysis from a dataset containing all the packets sent in the network during one month. Then we grouped the packets with respect to the transmitting ED, and we kept only the EDs that have sent more than 20 packets. At this point, we were able to compute the features of each device. These decisions lead us to a dataset composed of 1763 EDs, or samples, distributed between the three classes as shown in Table 3. As we can see from the Table 3, our dataset contains too few EDs in the class \"deep indoor\", so in the remainder, we focus our considerations on the classes \"mobile\" and \"fixed\". We expect similar results for the \"deep indoor\" class, should we have had a dataset including more EDs belonging to this class. In Figure 1, we have plotted the most interesting feature combinations, where the three classes are more distinguishable. As we can notice, the most representative features are std RSSI, std SNR, mean RSSI, and mean SNR, which will be used as descriptors for our samples. To enhance the flexibility of the soft SVM, we have also adopted the kernel method with the following kernel functions: linear kernel, polynomial kernel, and radial basis function kernel, which are usually used to introduce our prior knowledge in the learning algorithm for the classification problem. To select the best model to represent our samples we will use a validation set, which is a part of the dataset not used to train the algorithm. In our specific case, because the data is scarce and we do not want to \"waste\" precious samples on validation, we will use k-fold cross-validation. In k-fold cross validation, the original training set is partitioned into \(k\) subsets (or folds) of size \(m/k\). For each fold, the algorithm is trained on the union of the other folds and then the error of its output is estimated by using the fold. The average of these errors is the estimate of the validation \begin{table}
\begin{tabular}{c c c} \hline \hline
**Class** & **Type** & **Number** \\ \hline \multirow{2}{*}{_fixed_} & waste bin & 1506 \\ \cline{2-3}  & parking meter & 16 \\ \cline{2-3}  & ground humidity sensor & 14 \\ \hline \multirow{2}{*}{_mobile_} & tracker & 221 \\ \cline{2-3}  & water meter & 29 \\ \cline{2-3}  & environmental sensor & 7 \\ \hline \end{tabular}
\end{table} 
Table 2: Node types inside the LoRaWAN network. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Class** & **EDs** & **Percentage** \\ \hline _mobile_ & 153 & 8.68\% \\ _fixed_ & 1601 & 90.81\% \\ _deep indoor_ & 9 & 0.51\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Distribution of the filtered EDs between the three classes. error, which will be used to determine which is the best model. Then the algorithm is retrained using this model on the entire training set. To develop the SVM tool in Python we have used the package scikit-learn [24], which has implemented the SVM in the class sklearn.svm.SVC. Before the real part of machine learning, we performed a normalization process with the aim to normalize all the data inside the interval \([0,1]\), which is a fundamental step for the SVM techniques. To find out the best model to perform the predictions on our dataset we use the class sklearn.model_selection.GridSearchCV, which implements the SVM for all the possible parameter combinations in Table 4 and by means of k-fold cross-validation finds the best model for our data. The parameters required by the SVM implemented in scikit-learn are as follows. * C, which controls the precision in the classification. In other words, a high value of C aims at correctly classifying all the samples during the training phase, whereas a smaller value aims at a softer classification. It is related to the weights associated with the slack variables that we have introduced in the previous section.