# NetSel-RF: A Model for Network Selection Based on Multi-Criteria and Supervised Learning
## 3 NetSel-RF Model
### Data Preparation  
This phase analyzes and processes the initial dataset in order to build the final dataset. The data preparation involves the assessment of the quality of the dataset and the reduction the dataset's dimension. Firstly, we captured the data from the Mininet Wi-Fi emulator. We noted that the data for APs in the range of mobile devices were correct in the dataset. For APs which were out of range, there were missing values in the dataset. Therefore, we decided to substitute the missing values with the maximum value of each parameter. In particular, we assigned \(-100\) dBm for RSSI, \(100\%\) for AP occupation, and \(1\%\) for battery consumption. These maximum values in the dataset represent the non-selection of an AP outside the range of the mobile device.  
Secondly, we selected the most relevant features with the aim of reducing the dataset's dimension and the computational complexity. To determine the final dataset features, we applied three ML classification algorithms to all datasets resulting from the combination of all features of the initial dataset. In particular, we used HT, RF, and SVM because the output variable of these methods is categorical. HT is an incremental decision tree learner for large data streams, which assumes that the data distribution is not changing over time [20]. Additionally, HT uses the simple idea that a small sample can often be sufficient to choose an optimal splitting attribute, which is supported mathematically by the Hoeffding bound that quantifies the number of observations needed to estimate some statistics within a prescribed precision [35]. RF consists of a large number of individual decision trees that operate as an ensemble. Each tree predicts a class, and the class with the most votes becomes the prediction [36]. SVM outputs an optimal N-dimensional hyperplane (N--the number of labels) that categorizes the output variable given labeled training data [22].  
In this feature selection task, we used accuracy and MCC as metrics because they are typical in classification problems. Accuracy is the ratio between the number of correct predictions made and all predictions made [29]. MCC is a measure of the quality of classifications; it takes into account true and false positives and negatives. MCC is, in essence, a correlation coefficient value between \(-1\) and \(1\). A coefficient of \(1\) represents a perfect prediction, \(0\) an average random prediction, and \(-1\) an inverse prediction [24].  
For the sake of readability, Figure 3 depicts only the evaluation results of four tested datasets regarding accuracy and MCC. Dataset 1, in purple, includes RSSI, AP occupation, and battery consumption. Dataset 2, in green, considers RSSI, AP occupation, battery consumption, and distance. Dataset 3, in blue, comprises RSSI, AP occupation, battery consumption, and power consumption. Dataset 4, in orange, includes RSSI, AP occupation, battery consumption, distance, and power consumption. Dataset 1 obtained the best performance regarding accuracy and MCC for all evaluated ML algorithms. Specifically, this dataset obtained the highest accuracy, which was near to \(99.7\%\), and the highest MCC score, of around \(0.996\); thus, Dataset 1 was selected as the final dataset.  
Considering the accuracy and MCC results mentioned above, we reduced the dataset's dimension (i.e., resulting in lower computational complexity) from five to four input features; the final dataset (Dataset 1) includes the output variable AP\({}_{\text{target}}\) and the input features: AP available, RSSI, AP occupation, and battery consumption. Note that the final dataset does not include the distance feature (no relevant); this may be due to its relationship with battery consumption. We filled the final dataset by capturing the features/parameters when the device is in motion and has at least two APs in range; note that we assigned the maximum values to the missing data. Our final dataset comprises a total of \(10,500\) instances (see Table 4) [37].