# Anomaly Detection through Grouping of SMD Machine Sounds Using Hierarchical Clustering
## 2 Related Work
### Clustering-Based Anomaly Detection  
Clustering is a method of grouping objects in the same group so that they are more similar than those in other groups [16]. Clustering techniques used for anomaly detection include fuzzy c-means clustering (FCM) [17], K-means clustering [18], and hierarchical clustering [10]. [PERSON] et al. [19] demonstrated that hierarchical clustering was superior by comparing hierarchical clustering with k-means clustering and FCM, which are the most popular clustering techniques in anomaly detection, using the scientific data HTRU2 dataset [20] and tensile test dataset. [PERSON] et al. [19] purposed improved agglomerative hierarchical clustering (IAHC), which dynamically adjusts the clustering linkage modes and the number of clusters during the hierarchical clustering algorithm iterations. The IAHC selects the optimal clustering distance linkage mode by comparing the Cophenetic correlation coefficient \(c\)[21] calculated using Equation (11), considering single, complete, average, and centroid for each iteration of the algorithm. The Cophenetic correlation coefficient measures the similarity between individuals according to the following equation:  
\[c=\frac{\sum_{i<j}{[x(i,j)-\bar{x}][t(i,j)-\bar{t}\ ]}}{\sqrt{\sum_{i<j}[x(i,j)- \bar{x}]^{2}\sum_{i<j}([\bar{t}(i,j)-\bar{t}\ ]^{2}}}. \tag{11}\]  
Suppose that the data \(X_{i}\) have been modeled using a clustering method to produce a dendrogram \(T_{i}\), where \(x(i,j)\) is the Euclidean distance between the \(i\)th and \(j\)th observations, and \(t(i,j)\) is the dendrogramic distance (i.e., Cophenetic distance) between the model points \(T_{i}\) and \(T_{j}\). \(\bar{x}\) and \(\bar{t}\) are the average of \(x(i,j)\) and \(t(i,j)\), respectively. If the optimal clustering distance mode is selected by comparing the Cophenetic correlation coefficient, we find the optimal clustering number. To find the optimal number of clusters, we assume the number of \(n\) clusters in the optimal clustering distance mode, iterate algorithm \(m-1\) time, and then evaluate it as the criterion \(e_{n}\). The range of \(n\) follows \(n\in[2,m]\), where \(m\) is the maximum number of clusters of testing data according to domain knowledge. During the iteration of the algorithm \(m-1\) time, the average number of samples of the smallest cluster in each result is taken as the threshold \(T\). When the number of clusters is \(n\), we denote the number of samples in cluster \(i\) as \(k_{ni}\) where \(i=1,2,\ldots,n\). If \(k_{ni}\) is less than the threshold \(T\), we set \(l_{i}=1\); otherwise, \(l_{i}=0\). Then, \(L_{n}\) and centroid \(c_{ni}\) of the sample in each cluster is as follows:  
\[L_{n}=\sum_{i=1}^{n}l_{i},c_{ni}=\frac{1}{k_{ni}}\sum_{h=1}^{k_{ni}}x_{h}, \tag{12}\]  
where \(x_{h}\) represents the sample of the cluster \(i\), \(h\in[1,k_{ni}]\). The average distance of the centroids of clusters is calculated as follows:  
\[V_{n}=\frac{2}{n(n-1)}\sum_{j=i+1}^{n-1}d(c_{ni}-c_{nj}), \tag{13}\]  
where \(i\in[1,n]\). Looking at criterion \(e_{n}\) composed by \(L_{n}\) and \(V_{n}\), the optimum cluster number is the corresponding \(n\) with the maximum \(e_{n}\) calculated by the following equation:  
\[e_{n}=\frac{L_{n}}{\sum_{o=2}^{m}L_{o}}+\frac{V_{n}}{\sum_{o=2}^{m}V_{o}}. \tag{14}\]  
Autoencoder-based anomaly detection techniques [11; 14] introduced in Section 2.1 and clustering-based anomaly detection techniques [19] introduced in Section 2.2 are appropriate research studies for each task. However, it is not suitable to apply it to our tasks where data with new features keep increasing over time. If we apply an anomaly detection technique based on the autoencoder, we need to train the model every time new data are added; if we apply an anomaly detection technique based on clustering, domain knowledge can affect the performance; therefore, the criteria for clustering may be ambiguous.