## 6 Applying Machine Learning Based on Cloud Services
Figure 19 shows the confusion matrix obtained using eight decision trees, while Figure 20 shows the eight trees generated by the algorithm. Training time was 22 s.  
Figure 18: Confusion matrix from the evaluation with Multiclass Neural Network (500 nodes hidden layer, learning rate 0.1, 1000 learning iterations). Therefore, students can observe that Multiclass Decision Forest is well suited for the example project, since the algorithm offers better performance with less training time. Once the predictive model has been obtained, the next usual step in Machine Learning is the optimization of the results. Note that the prediction is made taking into account only two characteristics, the access point identifier (BSSID) and the received power, which can be very similar in different rooms. In this case, the goal will be to improve the dataset by adding new features that allow better classification performance. However, this process must be carried out with caution so as not to include too many feature that could generate very specific samples and limit the generalizability of the results in addition to increasing the risk of overfitting. Thus, unlike other methods of Wi-Fi positioning based on Machine Learning, we will try to introduce an estimate of the distance to the starting point where the robot begins to prowl and collect data from the Wi-Fi sensor (green circle in Figure 15), expanding the  
Figure 19: Confusion matrix from the evaluation with Multiclass Decision Forest, with 8 decision trees. Figure 20: Training Decision Trees generated by the Multiclass Decision Forest algorithm. dataset with new features. In this way, for each point, we can calculate the correlation of beam powers received at the point to compare with the correlation of the beam powers received at the origin, using Pearson's product-moment correlation:  
\[Corr(X,Y)=\frac{\sum_{i=1}^{n}(x_{i}-\mathbb{E}(X))(y_{i}-\mathbb{E}(Y))}{\sqrt{ \sum_{i=1}^{n}(x_{i}-\mathbb{E}(X))^{2}(y_{i}-\mathbb{E}(Y))^{2}}} \tag{14}\]  
where \(\mathbb{E}(X)\) is the mean of \(X\), \(\mathbb{E}(Y)\) is the mean of the \(Y\) values and n is the number of observations. To facilitate learning and interpretation, a scaling is performed based on the correlation coefficient that provides an estimate of distance in the range \([0...1000]\) (the lower the value, the greater the correlation and proximity):  
\[Index(X,Y)=\max\{k\in\mathbb{Z}\mid k\leq 1000\times(1-Corr(X,Y))\} \tag{15}\]  
In addition, we can also calculate the difference in the sum of powers of each access point at the current point and the origin. Both values could indicate an idea of distance to that defined origin. Furthermore, the number of new access points detected at the current point that were not detected at the origin, and the number of access points from the origin that remain at the current point, can be included as new features in the dataset as shown in Table 3.  
Figure 21 shows the new confusion matrix obtained by applying the Multiclass Decision Forest, again with 8 decision trees, but on the extended dataset. The training time was almost the same, 23 s.  
The advantage of the new features can be seen in the new decision trees generated, much simpler (as shown in Figure 22). Figure 23 shows the second tree in detail, in which it can be observed that the new features are combined to facilitate classification, taking into account context information, while in the previous case the decision trees were based only on two features with particular information.