## 4 Results
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Algorithm** & \(\mathbf{R^{2}}\) **Score** & **MaxError** & **MAE** & **MedianAE** & **RMSE** \\ \hline TAdBoost & 0.518 & 130.914 & 25.095 & 11.8 & 1811.6 \\ AdaBoost & 0.505 & 128.001 & 28.194 & 10.5 & 1996.6 \\ XGB & 0.420 & 123.850 & 35.307 & 19.9 & 2276.7 \\ Lasso & 0.409 & 118.322 & 37.179 & 22.2 & 2168.0 \\ Random Forest & 0.397 & 130.860 & 37.5 & 26.100 & 2201.6 \\ K-Neighbors & 0.244 & 132.400 & 42.6 & 31.200 & 2777.4 \\ SVR & \(-\)0.133 & 167.753 & 46.090 & 22.1 & 4147.7 \\ Kernel Ridge & \(-\)7.857 & 291.064 & 186.5 & 175.430 & 36,449.8 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Evaluation metrics. Figure 13: A portion of the occupancy data series obtained from the database and the prediction of the different methods against the real data. In the simulation, the nodes' distance, \(d_{n}\), was dynamically changed within a 10 km diameter to more realistically simulate mobile devices moving with respect to fixed fog servers. The latency calculations were performed using the following parameter values: \(D_{prop}=100e-6*d_{n}\), \(D_{proc}=1.6E-3\), and \(D_{queue}=1.5E-3+r*0.70E-3\), where \(r\) is a random variable between 0 and 1; note that \(D_{ser}\) was not considered in this work. Figure 15 displays the delay curve, which shows that fog computing reduces the overall delay. The reduction is not significant with fewer than 100 nodes, and, when there are fewer than 50 mobile phones, the delay is negligible, less than a second. However, as the number of requests increase, the delay with fog computing is almost half of that with cloud-only computing. Finally, with regard to study design, we assess both the internal validity and external validity of our study. Internal validity, in our context, focuses on two primary threats. Firstly, it pertains to the suitability of the dataset for training the algorithms. We have chosen a database containing 30 parking lots, for providing data for algorithm training. Secondly, it relates to the comparison of selected machine learning algorithms. To address this concern, we have opted for the most successful techniques commonly employed in the literature. External validity, in the context of our study, revolves around result generalization. There is a risk that the machine learning model may not perform effectively when applied to a parking lot not included in the database. However, we have implemented two strategies to mitigate this risk. Firstly, we selected machine learning algorithms known for their ability to recognize significant patterns in data, especially over extended periods, such as in time series analysis. These algorithms typically offer better generalization compared with more traditional methods like simple regression. Consequently, we anticipate that other parking lots will exhibit similar patterns to those on which the algorithm was trained. Secondly, even if generalization to other parking lots proves challenging, our fog nodes incorporate a retraining module. This module allows the algorithm to adapt to specific parking lots in the event of significant error levels, ensuring continued performance optimization.