## 4 Experimental Results and Analysis
### CSCL-Siamese Network Ablation Experiments  
In order to verify that the cost-sensitive contrastive loss function (CSCL) can effectively alleviate the deficiency of the recognition boundary shift due to the small number of positive pairwise samples, this experiment compares the Siamese (Siamese network based on contrastive loss function, CL-Siamese) network and CSCL-Siamese network for recognizing known IoT devices. The results of the ablation experiments of the CSCL-Siamese network are shown in Figure 12.  
As can be seen from Figure 12, the overall performance of the CSCL-Siamese network proposed in this paper is relatively better on the three different scenario datasets, which can all achieve high G-mean values. First, on the Aalto and UNSW datasets, the CSCL-Siamese network improves the ability to recognize positive pairs of samples by improving the traditional contrast loss function, leading to Recall improvements of 14.3% and 12.8%, respectively. However, this improvement also brought about a decrease in the Precision rate, 13% and 16%, respectively, as more negative pair samples were misclassified as positive pairs. Second, on the Aalto dataset and the UNSW dataset, the slight decrease in recognition accuracy (up to 2.8 percentage points) is exchanged for a larger increase in G-mean value (up to 7.4 percentage points), which indicates that the CSCL-Siamese network has made significant progress in balancing the recognition of both positive and negative pairs of samples, and that the overall recognition performance has been effectively improved. Therefore, sacrificing some accuracy is worth it. In addition, by comparing Figure 12a-c, it can be seen that the recognition effect of the CSCL-Siamese network on the LSIF dataset is higher than that of the other two datasets, and all the evaluation metrics are better than that of the traditional CL-Siamese network, which on the one hand, indicates that the CSCL-Siamese network has a better recognition ability for IoT devices in the idle state of the traffic data, i.e., the LSIF dataset has a better recognition ability; on the other hand, it also verifies that the CSCL-Siamese network can alleviate the shortcoming of the recognition boundary shift due to the small number of positive pairs of samples, and has a certain degree of adaptability to the IoT device traffic data in different scenarios. In addition, in order to verify the superiority of the proposed cost-sensitive contrast loss function, compared to the traditional contrast loss function, in reducing the loss values in the set of PNSPs, the change of the loss values with the increase in the number of training rounds is further compared between the CL-Siamese network and the CSCL-Siamese network, as shown in Figure 13, where the blue dashed line shows the change in loss values for the CL-Siamese network and the yellow solid line shows the change in loss values for the CSCL-Siamese network.  
Figure 11: Comparison results of two algorithms for recognizing known IoT devices.  
Figure 12: Experimental results of ablation of CSCL-Siamese network.  
Figure 13: Plot of the change process of the loss value of the two networks.  
As can be seen in Figure 13, the loss value of the CSCL-Siamese network has a more significant reduction compared to the CL-Siamese network. At the first iteration, the loss value of the CSCL-Siamese network has reached about 0.043, which is 8.8 percentage points lower compared to the CL-Siamese network. As the number of iterations increases, after 16 iterations, the loss value of the CSCL-Siamese network reaches a minimum point of only 0.034. However, in the subsequent iterations, the loss value of the CSCL-Siamese network appears to fluctuate back and forth with changes, which may be due to some stochastic factors in the training process or the model itself. Nevertheless, in terms of the overall trend, the CSCL-Siamese network still outperforms the CL-Siamese network in terms of the overall performance on the loss value, and is able to reduce the loss value effectively.