# Wi-Fi Fingerprint-Based Indoor Localization Method via Standard Particle Swarm Optimization
## 3 System Overview
### SPSO Algorithm for Localization
The mean of each 30 measurements from the 10 APs were taken as the fingerprint of the RP. Further, the approximately uniformly distributed 52 groups of RPs with over 2.0 m spacing, and the corresponding fingerprints, constituted the training dataset, a sparse set; the remaining 135 groups constituted the test dataset and were used to test the performance of the localization system during the localization process. ### Performance Metric

To evaluate the localization performance, several evaluation indices in machine learning were applied. The mean squared error (MSE), mean absolute error (MAE), root MSE (RMSE), and standard deviation (STD) were adopted as the main performance metrics. Furthermore, the mean of the Euclidean distance between the estimated location and the actual location was considered as a measure of accuracy. These metrics are defined as follows. \[\text{Error}_{MSE}=\frac{1}{N_{te}}\sum_{i=1}^{N_{te}}\left[({x_{p}}_{i}-{x_{ test}}_{i})^{2}+({y_{p}}_{i}-{y_{test}}_{i})^{2}\right] \tag{19}\]

\[\text{Error}_{MAE}=\frac{1}{N_{te}}\sum_{i=1}^{N_{te}}\left(\left|{x_{p}}_{i }-{x_{test}}_{i}\right|+\left|{y_{p}}_{i}-{y_{test}}_{i}\right|\right) \tag{20}\]

\[\text{Error}_{RMSE}=\sqrt{\frac{1}{N_{te}}\sum_{i=1}^{N_{te}}\left[\left({x_ {p}}_{i}-{x_{test}}_{i}\right)^{2}+\left({y_{p}}_{i}-{y_{test}}_{i}\right)^{2 }\right]} \tag{21}\]

Figure 3: (**a**) The indoor environment. (**b**) The data-collection device. Figure 2: Layout of the experiment area (the dots represent the locations of all reference points). \[ \begin{split}\text{Error}_{STD}&=\sqrt{\frac{1}{N_{te}} \sum_{i=1}^{N_{te}}\left(err_{i}-\overline{err}\right)^{2}},\\ err_{i}&=\sqrt{\left(x_{p\,i}-x_{test\,i}\right)^ {2}+\left(y_{p\,i}-y_{test\,i}\right)^{2}},\\ \overline{err}&=\text{Accuracy}=\frac{1}{N_{te}} \sum_{i=1}^{N_{te}}err_{i}\end{split}  \tag{22}\]

where \((x_{p},y_{p})\) is the estimated location obtained by the localization algorithm and \((x_{test},y_{test})\) is the actual location of the RSS collection device. ### Results and Discussion

#### 4.3.1 Performance Comparison of Different Methods

To evaluate the localization performance of the proposed system, it was compared with four other classical machine-learning (ML) algorithms: (1) the K-nearest-neighbor (KNN) method [44]; (2) the support-vector-machine (SVM) method [45]; (3) the linear-regression (LR) method [46]; and (4) the random-forest (RF) method [47]. All the ML-based results were calculated on a computer with 16.0 GB of RAM, Intel(R) Core(TM) i7-10700 CPU and the program environment of Python 3.7.8. A quantitative analysis of the localization errors was performed, as shown in Table 2. It shows that the four performance metrics of the proposed localization system were all minimum except for the STD, with MSE 6.0433 m, MAE 2.6288 m, and RMSE 2.4583 m, which is also shown in Figure 4. However, the difference in STD from the minimum was less than 0.04. Meanwhile, it is evident that it exhibited the best performance on the basis of 25/50/75% error, implying that the percentage accounted for all localization errors. In particular, the 50% error was less than 2.00 m and the 75% error was within 3.00 m. In terms of the improvement rate of RMSE, improvements by 11.25 16.28 33.56 and 36.76% compared with KNN, SVM, LR and RF, respectively, were observed. In general, the proposed method exhibited the best performance. The CDF curve and the box plot can represent the localization performance and the distribution of the localization errors, in a visualized manner, as in Figure 5a,b, respectively. It is clear that the performance of SPSO is better than that of the other four. For LR and RF, their performances were not that different and were relatively mediocre. However, the performances of KNN and SVM were moderate. In the box plot, it is evident that, regardless of the median, maximum, minimum, upper quartile, or lower quartile, the localization error of the proposed method is the lowest, and no extreme outliers exist (outliers are shown as * in Figure 5b).