## 2 Proposed Localization System
### Online Phase
#### 2.2.2 Adaboost Algorithm  
Adaboost is an adaptive boosting algorithm that combines multiple weak classifiers into a strong classifier. However, the standard Adaboost algorithm is designed for binary classification [37]. To address the multi-grid localization problem, the binary classifier can be extended to a multi-class classifier. This extension involves training \(K\) Adaboost classifiers, where each classifier pair distinguishes one localization region from another, with \(K=\frac{L(L-1)}{2}\).  
The specific procedure of the proposed implementation of the Adaboost algorithm consists of the eight steps presented in Algorithm 1. The inputs include the fingerprint information for each grid and the corresponding class labels. The output is the trained Adaboost model. Let \(FP_{m}\) represent the fingerprint data and \(y_{i}\) the associated class labels. The weight distribution of sample \(FP_{m}\) at iteration \(t\) is denoted by \(w_{t}(m)\), while \(h_{t}\) is the decision function of the weak classifier \(\mathbb{C}_{t}\), with \(h_{t}(FP_{m})\in-1\), \(+1\) representing the class label assigned by \(\mathbb{C}_{t}\) to sample \(FP_{m}\).  
```
0: Training sample set \(\mathbf{D}=(FP_{1},y_{1}),\cdots,(FP_{m},y_{m}),FP_{m}\in FP,y_{m}\in Y=\{-1,+1\}\); \(T\): Number of iterations; \(\mathbf{C}\): weak classifier.
1:\(w_{1}(m)=1/M,m=1,2,\cdots,M\)
2:for\(t=1,2,...,T\)do
3:\(h_{t}=C(D),w_{t})\)
4:\(\varepsilon_{t}=\sum_{m=1}^{M}w_{t}(m),y_{m}\
eq h_{t}(FP_{m})\)
5:if\(\varepsilon_{t}>0.5\) then break
6:\(\alpha_{t}=\frac{1}{2}\ln\left(\frac{1-\varepsilon_{t}}{\varepsilon_{t}}\right)\)
7:\(w_{t+1}(m)=\frac{w_{t}(m)\exp\{-\alpha_{t}y_{m}h_{t}(FP_{m})\}}{Z_{t}}=\frac{w_ {t}(m)}{Z_{t}}\times\left\{\begin{array}{ll}e^{-\alpha_{t}},&\text{if }y_{m}=h_{t}(FP_{m})\\ e^{\alpha_{t}},&\text{if }y_{m}\
eq h_{t}(FP_{m})\end{array}\right.\)
8:endfor
```  
**Output**: Adaboost classifier: \(H(FP)=\text{sign}\Big{[}\sum_{t=1}^{T}\alpha_{t}h_{t}(FP)\Big{]}\) ```  
**Algorithm 1** Adaboost-Based Fingerprint Indoor Localization Algorithm  
Initially, each sample is assigned an equal weight (Step 1), i.e., \(w_{1}(m)=\frac{1}{M}\). The iteration proceeds from Step 2 to Step 8 for \(T\) iterations, corresponding to the number of weak classifiers. The dataset weights \(w\) are updated in each iteration based on the prediction results and the error rate of the weak classifier. The iteration ends if the error rate exceeds 0.5. Otherwise, the weights of the weak classifier and samples are updated in Steps 6 and 7, respectively. The normalization coefficient \(Z_{t}\) ensures that the sum of the weights remains equal to 1, i.e., \(\sum_{m=1}^{M}w_{t+1}(m)=1\).  
We choose the decision tree as the weak classifier, with the following key parameters:  
* **Maximum depth of the decision tree (max_depth)**: To prevent overfitting, the number of fingerprint features should be optimized by limiting the value of _max_depth_(=3).
* **Class weights (class_weight)**: Before training the model, it is important to evaluate the sample distribution across classes. If the class distribution is imbalanced, we adjust the class weights (_class_weight_=1) to prevent bias towards classes with more samples.
* **Minimum sample size required for internal node partition (min_samples_split)**: If the number of samples in a node is less than _min_samples_split_(=60), no further feature selection is performed for splitting. For larger sample sizes, this value could be increased.
* **Minimum sample size for leaf nodes (min_samples_leaf)**: This parameter sets the minimum number of samples required for leaf nodes. If the sample size of a leaf node is less than _min_samples_leaf_(=5), pruning is performed on that leaf and its siblings.  
We used the trained Adaboost algorithm to classify the data in the fingerprint database, with the output being the position corresponding to each fingerprint.