# A REM Update Methodology Based on Clustering and Random Forest
## 3 Proposed Approach for REM Updates  
### Overview  
Figure 2 illustrates an overview of the proposed approach to REM updates based on clustering and the RF algorithm. First, assume the initial dataset is \(D_{H}=\left\{\mathbf{z}_{1},...,\mathbf{z}_{n},...,\mathbf{z}_{N}\right\}\), where \(N\) is the total number of collected historical measurements and \(\mathbf{z}_{n}=\left\{x_{n},y_{n},R_{n}\right\}\), in which \(x_{n}\) is the location in the \(x\)-axis, \(y_{n}\) is the location in the \(y\)-axis, and \(R_{n}\) is the RSSI value at position \((x_{n},y_{n})\). The initial module of the proposed approach conducts clustering. In particular, we consider the \(K\)-means algorithm where \(N\) samples are separated into \(K\) groups. A detailed description of the \(K\)-means algorithm can be found in Section II of [19]. The \(K\)-means algorithm is applied to initial dataset \(D_{H}\) to obtain \(K\) cluster centers, which are used to assign each \(n\)-th sample to one of the \(K\) clusters based on the nearest centroid. The second module, based on the RF algorithm, is where we train one RF model per cluster. Once each \(n\)-th measurement of dataset \(D_{H}\) has been assigned to a cluster, we have \(D_{k}=\left\{\mathbf{z}_{1_{k}},...,\mathbf{z}_{m_{k}},...,\mathbf{z}_{M_{k}}\right\}\) at the \(k\)-th cluster with \(k=1,...,K\) and \(\mathbf{z}_{m_{k}}=\left\{x_{m_{k}},y_{m_{k}},R_{m_{k}}\right\}\). Then, \(K\) RF models are trained based on the corresponding dataset \(D_{k}\). A detailed description of the RF algorithm is presented in Section 3.2. Once we have the \(K\)-trained RF models, we construct a grid, \(G=\left\{\mathbf{f}_{1},...,\mathbf{f}_{h},...,\mathbf{f}_{H}\right\}\), where \(H\) is the total number of samples in the grid, and \(\mathbf{f}_{h}=\left\{x_{h},y_{h}\right\}\). The grid is created to cover the whole area of interest and corresponds to the positions to be estimated by the RF algorithm. Next, each \(\mathbf{f}_{h}\) is assigned to one cluster, and the corresponding RSSI value in that cluster is predicted by the RF model. Then, we construct the REM by using the location coordinates and by mapping the RSSI values to a specific color in a color map. A detailed description of REM construction is presented in Section 3.3. Figure 1: Floor plan of the room used for the experimental evaluations. Next, we consider the REM update, denoted as \(\mathbf{t}_{1}\) in Figure 2, based on newly collected measurements. Once we have trained the RF models based on the historical dataset, we apply the procedure to update the REM because the wireless environment constantly changes over time. For instance, in a smart warehouse, the positions of the products constantly change during the day. In general, the proposed scheme for the REM updates is based on training the RF models with newly collected data only in clusters with enough samples. We denote the newly collected dataset as \(D_{\mathbf{t}_{1}}=\left\{\mathbf{z}_{\mathbf{t}_{11}},...,\mathbf{z}_{\mathbf{ t}_{n_{1}}},...,\mathbf{z}_{\mathbf{N}_{\mathbf{t}1}}\right\}\), where \(N_{\mathbf{t}1}\) is the number of newly collected measurements at the time \(\mathbf{t}_{1}\), and \(\mathbf{z}_{\mathbf{n}_{t}1}=\left\{x_{\mathbf{n}_{t1}},y_{\mathbf{n}_{t1}}, R_{\mathbf{n}_{t1}}\right\}\). First, we assign each \(n_{\mathbf{t}1}\)-th sample to one of the \(K\) clusters, which creates \(K\) possible datasets, each of them denoted \(D_{k_{\mathbf{t}_{1}}}=\left\{\mathbf{z}_{1},...,\mathbf{z}_{\mathbf{n}_{k1} },...,\mathbf{z}_{\mathbf{M}_{k,\mathbf{t}1}}\right\}\). Since the newly collected measurements are not guaranteed to cover the whole area of interest, some datasets may contain no (or a very small number of) samples, which can lead to degradation when training the new RF model.