# Poisoning Attacks against Communication and Computing Task Classification and Detection Techniques
## 6 Poisoning Attack Detection  
Anomaly detection (AD) is a data analysis approach that identifies patterns, instances, or observations that differ significantly from normal behavior in a dataset. AD can be accomplished using a variety of statistical, machine learning, or data mining approaches. In our case, because the dataset consisted of several distinct clusters that followed Gaussian distributions, the Gaussian mixture model (_GMM_) [43] was considered to characterize the 2C task features. The GMM is a probabilistic model used for representing complex data distributions as a combination of multiple Gaussian distributions. It assumes that the observed data are generated by a mixture of underlying Gaussian components. Each component in the GMM reflects a Gaussian distribution defined by its mean and covariance. To reflect the overall distribution of the data, the model combines these differentiated Gaussian distributions with mixing coefficients. The poisoning attack mitigation technique proposed is based on anomaly detection of the poisoning examples. Once they are detected, they are likely to be removed from the dataset. The proposed AD technique is a semi-supervised learning technique used to detect anomalies by modeling the usual behavior of a dataset (reference dataset) and finding data points that vary considerably from this learned normal distribution. As a result, the only possible solution is to have some history of old generated requests by sources representing the 5G and 6G services. The decision about the anomalous examples is accomplished by using a threshold that represents the maximum 3D position that is far from the cluster's centroid. Hence, examples that are located far from the clusters' centroids are said to be anomalous. The other examples with positions near the clusters' centroids are said to be legitimate. This threshold is determined by the percentile of the GMM's log-likelihood _score_sample_ quantity from the _Scikit-learn_[44]_GMM_ class. For _attack1_, the examples to be monitored are all the dataset examples, while for _attack2_, the monitored examples are the centroids of each cluster, since the aim is to detect the whole malicious cluster. Anomaly detection using the GMM for this attack is named _method1_. For _attack2_, two scenarios might be distinguished: (1) when the malicious cluster is separated well from the legitimate groups and (2) when it intersects with one or more of the legitimate clusters. For this, the _silhouette score_ test [45] was employed to first identify the optimum number of clusters the dataset set could be divided into and second, from the system's history and based on the dataset shape, define the number of legitimate clusters L. Hence, if the _silhouette score_ refers to a greater number of clusters than L, then anomaly detection is run to detect the malicious centroid. If the detected malicious cluster is found to be intersecting with legitimate clusters, then _quantile-quantile_ (Q-Q) plots [46] are used to separate it. Anomaly detection using the GMM with the _silhouette score_ and Q-Q plots is named _method2_. To summarize, the following apply to (A) application of the detection for _attack1_:  
1. Obtain the optimum number of clusters k in the data using the silhouette score test. 2. Train the GMM model offline with all the examples used as history. 3. Check if the model has intersecting clusters using Q-Q plots for each group. If the line of the plot is not straight compared with the Gaussian distribution reference, then the group is detected as not being Gaussian distributed. Hence, a possible intersection is present, and k is incremented by the amount of intersections detected. 4. Fit the GMM on the model. 5. For each example in the dataset, its 3D position log-likelihood is compared to the threshold. If it is greater than the threshold, then it is anomalous (i.e., the example located far from the centroid of the associated cluster).