# Bootstrap-CURE: A Novel Clustering Approach for Sensor Data--An Application to 3D Printing Industry
## 5 Methodology
### Determining the Number of Clusters: Calinski-Harabasz Index  
In any hierarchical clustering algorithm, the number of clusters emerges after plotting the dendrogram and optimizing both the homogeneity and the distinguishability of the clusters. There is an abundance of works in the literature available, dealing with the evaluation and performance of clustering [97; 98; 99]. A robust evaluation measure was provided by the Calinski-Harabasz index [76], also popularly known as the _variance-ratio_ method. The Calinski-Harabasz index, for a clustering solution \(P\) consisting of \(k\) clusters from a dataset having \(n\) rows, is calculated as follows:  
\[CH(k)=\frac{B_{k}/(k-1)}{W_{k}/(n-k)} \tag{3}\]  
where \(k\) is the number of clusters. \(B_{k}\) is the between classes variability, defined as  
\[B_{k}=\sum_{C\in P}n_{C}\;\mathrm{d}\left(\bar{l}_{C},\bar{l}\right)^{2} \tag{4}\]  
and \(W_{k}\) is the within classes variability, defined as  
\[W_{k}=\sum_{C\in P}\sum_{i\in C}\mathrm{d}\left(\mathrm{i},\bar{l}_{C}\right) ^{2} \tag{5}\]  
\(\bar{l}_{C}\) is the centroid of the cluster \(C\), \(n_{C}\) is the size of cluster \(C\), and \(\bar{l}\) is the centroid of the whole dataset. In theory, the number of clusters obtained by using the _Calinski-Harabasz_ method should match with the number of clusters deduced by the experts looking at the dendrogram. In the earlier work by [PERSON] et al. [78], the authors evaluated five different criteria based on the _Calinski-Harabasz_ index over 100 datasets of varying size and assessed the validity of those five criteria in regards to visual inspection by human experts. In practice, a human expert usually finds the best cut of the dendrogram, finding the branches with a wider vertical gap between consecutive nodes. The final clusters correspond to the branches of the tree isolated by the horizontal cut. The result of the experiments performed in [88], however, indicated all criteria based on the Calinski-Harabasz index to be underperforming. It was also evidenced that the _Calinski-Harabasz_ index does not align with real expert practices well enough. Thus, [PERSON] et al. proposed two new criteria to overcome this limitation based on the heights of the internal nodes of the dendrogram that better follow the real practicesperformed by experts and prove that the criterion \(\Delta_{H_{cond}}\) is the one that better approaches that of experts. This is the criteria proposed to be included in the general methodology proposed in Section 5.1.1  
Let \(h_{\
u},\
u\in 1:n-1\) be the height of node \(\
u\) in a given dendrogram built over a dataset \(I\). The values of \(h_{\
u}\) depend on the linkage method used in the hierarchical process that generates the dendrogram. The \(\Delta_{H_{cond}}\)[88] is defined as follows:  
\[K^{*}_{\Delta_{H_{cond}}}=\left\{ \begin{array}{ll}K^{*}_{2\Delta_{H}}&\text{ if }K^{*}_{\Delta_{H}}=2\text{ and }(h_{2}/h_{root})>1/3\\ K^{*}_{\Delta_{H}}&\text{otherwise}\end{array} \right. \tag{6}\]  
where \(h_{root}\) and \(h_{2}\) represent the heights of the two highest nodes of the dendrogram and the \(K^{*}_{\Delta_{H}}\) and \(K^{*}_{2\Delta_{H}}\) are the maximum and second maximum of the \(\Delta_{H}\) criterion as defined in [78]:  
\[K^{*}_{\Delta_{H}}=\operatorname*{argmax}_{2\leq k\leq K}(\Delta_{H_{k}});k \in(2,3,\ldots K-1) \tag{7}\]  
where  
\[\Delta_{H_{k}}=h_{k}-h_{k+1};k\in(2,3,\ldots K-1) \tag{8}\]  
It is shown empirically that the \(\Delta_{H}\) criterion underperforms where the best cut of the tree is two clusters, as experts are biased toward this scenario and use a heuristic to skip the two clusters' cut sometimes. The modified criterion, defined as, The \(\Delta_{H_{cond}}\) incorporates this heuristic by introducing the concept of the _height factor_ as a ratio between the heights of the two highest nodes of the dendrogram.