# Mobility Classification of LoRaWAN Nodes Using Machine Learning at Network Level
## 3 Machine Learning Algorithm  
The aim of this work is to find a technique to classify the EDs in a LoRaWAN network into the following three categories: fixed, mobile, and deep indoor. The main idea is to use a machine learning approach and find a function that is able to predict the category of the EDs, starting from the information collected by the received packets at the GWs. We suppose to have a very small set of EDs that are already labeled, whose reception data, collected at the gateway, can be used as the training set for our algorithm. This set will be our ground truth. It is important to clarify that the resultant function of the algorithm for the categorization of nodes will be specific to the LoRaWAN deployment where it was computed. To reach our goal, we will use a supervised learning algorithm, the support vector machine (SVM). SVM is a very useful machine learning tool for learning linear predictors in high-dimensional feature spaces. The main idea behind SVM is to find the best boundary (or hyperplane) that separates the different classes in a dataset by maximizing the margin, which is the distance between the hyperplane and the closest data points from each class. These points are the so-called support vectors; in fact, because they are the closest points tothe decision boundary, they have the most impact on the position of the hyperplane. SVM is particularly useful when the data have many features, or when the classes are highly nonlinear. The algorithm's ability to handle nonlinearly separable data is obtained with the kernel method technique, which transforms the data into a higher-dimensional space where the data points become linearly separable. This enables SVM to model complex, nonlinear decision boundaries that cannot be classified by other linear methods. Furthermore, SVM is a robust algorithm that is not affected by the presence of noise or outliers in the data. With the regularization parameter \(C\) it can be possible to balance the tradeoff between maximizing the margin and minimizing the classification error. In this paper, we use the soft version of the SVM and the kernel method, which enables us to enrich the expressive power of halfspaces by first mapping the data into a high-dimensional feature space, and then learning a linear predictor in that space [23]. The proposed algorithm running on a computer with a ninth generation i7 CPU and an RTX 2060 GPU takes around one minute for the training phase, and it is almost immediate for the testing phase. The creation of the features to represent the nodes is done by collecting the reception information of the packets from every device; in particular, we will use: the packet received signal strength indication (RSSI), the packet signal-to-noise ratio (SNR), the number of gateways receiving the packet from the same ED and the number of packet transmissions for every successful packet reception. After the reception of some packets from the same ED we can compute the node features described in Table 1. We remark that we do not use all these features in the table to represent a node, but select only the ones that are most representative for the EDs of the specific LoRaWAN network. In fact, the more feature we use, the bigger the dimensionality of the problem becomes, with the risk of overfitting the dataset. The main reason behind this is that the employed dataset is too small for the use of a too-high dimensional feature space. So from repeated tests, we have found that the most representative features are: std RSSI, std SNR, mean RSSI and mean SNR. After selecting the features, the training set of EDs (typically around a few hundreds of EDs) to get the classification function takes place. By using the training set we can select