## 4 Case Study
The minimum and maximum number of words are reported for each dataset, as well as the average, standard deviation, and median. Moreover, the 25 th and 75 th percentiles are included (i.e., the number of words for 25% and 75% of the documents, respectively). Figure 1: Distribution of number of words, in terms of (**i**) the original corpus of documents and (**ii**) the pre-processed corpus of documents. \[s(i)=\frac{b(i)-a(i)}{\max(a(i),b(i))} \tag{10}\]  
\[Silhouette\_score=\frac{1}{n}\sum_{i=1}^{n}s(i) \tag{11}\]  
On the other hand, _Inertia_ measures the sum of the squared distances between each data point and the centroid of its cluster, hence representing how compact the clusters are. Smaller values indicate higher quality of compactness. It is calculated as the sum of the within-cluster sum of squares for each cluster \(C_{k}\) (Equations (12) and (13)):  
\[WOSS_{k}=\sum_{i\in C_{k}}dist(d_{i},\mu_{k})^{2} \tag{12}\]  
\[Inertia=\sum_{k=1}^{K}WOSS_{k} \tag{13}\]  
Figure 2 illustrates the results obtained for three distinct algorithms, namely, _K-Medoids_, _K-Means_, and _DBSCAN_. Based on the results reported in Figure 2, we elected to utilize the _K-Medoids_ algorithm with two distinct clusters, maintaining a meaningful balance between computation cost and performance. While _DBSCAN_ managed to obtain a substantially higher _Silhouette_ value, it was disregarded, as the analysis of the results showed that the clusters formulated were highly imbalanced. Table 2 summarizes the statistical information concerning the textual attributes for the documents of each cluster. As observed, while the clusters formulated were rather balanced, the number of documents for each cluster remained large, hence rendering crucial the necessity of generating summaries for each cluster. The XAI models utilized to gain insights and provide meaningful explanations about the clustering process were developed with the Python programming language; we particularly relied on the _PyTorch_, _LIME_, and _SHAP_ libraries. For each document, we can create an interactive HTML file using the SHAP library, where users can click on individual words to examine their significance. Similarly, _LIME_ generates either a list of words that are significant for the prediction or an HTML file containing the original text with the most important words highlighted. Figure 3 illustrates an example of a document analyzed with SHAP, while Figure 4 presents the LIME output for the same document. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline  & & & & & **Word Statistics** & & \\ \hline
**cluster\_id** & **\# Documents** & **Min** & **Max** & **Average** & **STD** & **Median** & **25\%** & **75\%** \\ \hline
**0** & 943 & 10 & 592 & 72.96 & 68.57 & 54 & 34 & 87 \\ \hline
**1** & 1234 & 10 & 581 & 119.66 & 102.73 & 83.5 & 49 & 151 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Statistics of the documents for each cluster. The minimum and maximum number of words are reported for each dataset, as well as the average, standard deviation, and median. Moreover, the 25 th and 75 th percentiles are included (i.e., the number of words for 25% and 75% of the documents, respectively). Figure 2: The _Silhouette_ and _Inertia_ plots obtained by running each algorithm multiple times with varying numbers of clusters. Concerning _DBSCAN_, we do not report the _Inertia_ results, as the concept of _Inertia_ only applies to partition-based clustering algorithms. _K-Medoids_ overall demonstrated better results across each experiment, while using the _ELBOW_ method we can extract from the figures that the best option concerning the number of clusters is two. Figure 4: The output of LIME for a document; users can examine either the generated list of important words or the text with highlighted words. Figure 3: The output of SHAP for a document; users can interact with each word, to view its significance.