# Explainable Machine Learning for LoRaWAN Link Budget Analysis and Modeling
## 3 Implementation and Results
### Data Analysis and Result  
Dataset is divided into training and holdout sets, each with 4007 and 1000 samples respectively. The training set is used for 5-fold cross-validation (CV) and hyper-parameter tuning. The holdout set is used for benchmarking the tuned models. All the algorithms are trained and tuned using a 5-fold CV, which involves multiple exhaustive hyperparameter tuning using grid search. Where possible, early stopping along with regularization were used to avoid overfitting. To enable a comparative analysis of various algorithms, FSPL is used to establish a baseline against which the effectiveness of the other propagation variables that are extracted and used for machine learning can be compared. A regression analysis involving the pre-calculated FSPL is formulated in Equation (1), where \(\widehat{\text{RSSI}}\) is the model estimations. \[\widehat{\text{RSSI}}=\text{intercept}+\text{coefficient}\times\text{FSPL} \tag{1}\]  
In this optimized model, the FSPL's parameters are intercept of 39.43 and a slope coefficient of \(-1.66\), representing the best-fitted line. Figure 2 demonstrates this optimization, where the model achieved an RMSE of 9.01 dBm. Given the frequency of 865.20 MHz, theFSPL was calculated using the distance (\(d\)), which varied from 67.68 to 2275.36 m. The FPSL correspondingly spanned a range of 67.74 to 98.27 dB, depicted on the x-axis of Figure 2.  
Next, linear Regression (LR) was applied to the dataset. Characterized by its simplicity and interpretability, linear regression aims to find the best linear fit by approximating a hyperplane to the data, presuming a linear relationship between all 13 of the propagation variables and the RSSI. This effectively forms a new propagation model by taking advantage of all the propagation variables. LR creates this new propagation model by linearly combining all the variables, and it comprises 14 coefficients. This is utilized as a rudimentary approach for estimating LoRa's propagation and resulted in a root mean squared error (RMSE) of 8 dBm. This also demonstrates that added features, in addition to FSPL, can immediately improve the model's performance. Subsequently, polynomial regression (PR) was adopted to examine more complex relationships within the propagation variables. This facilitated the transformation of features into a higher-dimensional space, thereby allowing the model to form inherently nonlinear associations between these variables. Although polynomial regression is suited to addressing non-linear patterns, it incurs increased computational complexity due to expanding the number of features. Hyperparameter tuning resulted in a polynomial of degree 3, which transformed the 13 propagation variables into 560 features. A total number of features can be derived using the binomial coefficient in Equation (2), where \(n=13\) is the number of features, and \(d=3\) is the degree of the polynomial. \[\left( \begin{matrix}n+d\\ d\end{matrix} \right)=\frac{(n+d)! }{n!\times d!}=\frac{16! }{13!\times 3! }=560 \tag{2}\]  
This expanded feature space suited the complexities inherent in LoRa's propagation characteristics, as the RMSE was reduced to 6.65 dBm, while model parameters grew from 14 to 561. Hyperparameter tuning examined many different MLP architectures, where the best performance was achieved from four hidden layers, each with seven neurons. The total number of parameters was, therefore, 274, making the model very lightweight, fast, and accurate. It was noted that the hyperbolic tangent activation function was selected by the tuning algorithm, which resulted in an RMSE of 6.85 dBm. ANFIS, with a 5-fold CV, achieved an RMSE of 7.16; however, when trained with only 30% of the data, it still maintained an accuracy of 8 dBm, making it a good choice for very small datasets. Figure 2: Comparing the optimized FSPL against measured RSSI. The SVM achieved results similar to the MLP, with an RMSE of 7.03 dBm. The radial basis kernel function was used to map the data into a higher-dimensional space and handle the non-linearity of the data.