## 4 The Application Model of Machine Learning in Wireless Sensor Networks
### The Data Fusion Algorithm of the Wireless Sensor Network Machine Learning Model  
After classification, the sensor hub data must be fused; so the model must be trained to compare the data extracted by the machine learning classification [26]. As the tests do not contain named data, an unsupervised data fusion calculation SAE-MDA1 based on SAEM1 and a supervised data fusion calculation SAE-MDA2 based on SAEM2 were designed. To facilitate the comparison and analysis, the WSN using the SAEMDA algorithm had the same network model as similar networks. First, we clustered the network through the clustering protocol and selected the cluster head node of each cluster; then, we ran the SAE-MDA1 algorithm (as shown in Figure 5) and the SAE-MDA2 algorithm. The main steps of the algorithm were as follows:  
1 SAEMDA1  
**Step 1** Each cluster hub collected the sensor data and sent them to the comparison cluster head hub without processing.  
**Step 2** The cluster head built and prepared the SAEM1 algorithm model based on the obtained cluster center data. At this time, the cluster head transmitted the SAE parameters to each cluster center, and the cluster head retained the K cluster parameters.  
**Step 3** The cluster hub collected the detected data, employed the obtained SAE to extract the data features, and sent them to the cluster head.  
**Step 4** The cluster head used the K-means cluster to classify features and fuse similar features according to Formula (21) and then sent them to the sink node  
\[f_{c}=\frac{1}{n_{c}}\sum_{i=1}^{n_{c}}a^{(N_{b},n_{l})(i,c)},\ c=1,\cdots,N_{c}. \tag{21}\]  
2 SAEMDA2  
**Step 1** Each cluster head hub sent the cluster hub data table to the sink node.  
Figure 5: Wireless sensor machine learning SAEMDA1 algorithm flow.  
**Step 2** The conglomeration hub developed and trained the SAEM2 with the training data containing named data as the input. At that point, the sink hub sent the SAE parameters back to each cluster hub and the SoftMax classifier parameters back to each cluster head node.  
**Step 3** The cluster hub collected the detecting data and employed the SAE to extricate the features, sending them to the cluster head.  
**Step 4** The cluster head employed the SoftMax classifier to classify the features and fused the similar features according to Equation (2); after that, it sent them to the sink node.  
The SAEMDA2 had a lower time complexity because it had a shorter BP network and was trained in the convergence nodes, while the SAEMDA1 trained the SAEM1 network in the cluster head, and the cluster head needed to receive the original data sent by the cluster nodes as training samples, which increased the time and space complexity; in addition, the feature extraction and classification were performed in the cluster head in the SAEMDA1, while in the SAEMDA2, the cluster nodes performed the feature extraction locally, and the cluster head only performed the classification fusion, which reduced the amount of data transmission; therefore, the energy consumption of the SAEMDA2 was lower than that of the SAEMDA1.  
For the SAEM1 and SAEM2 models of wireless sensor machine learning, the number of input layer units was the same as the collected data, and there were no specific parameters for organizing clusters and cluster centers. Therefore, the operation of the SAEMDA algorithm and the clustering convention of the wireless sensor machine-learning display were independent from each other.