## 4 Case Study
### The Benchmark K-Means Method for Time-Series Clustering  
The \(K\)-means algorithm is a widely adopted and efficient method for clustering data and possesses numerous advantages such as simplicity, speed, robustness, and the ability to address temporal resolution effects [30]. Furthermore, its shape-preserving capabilities render it ideal for data clustering. These characteristics make it a suitable benchmark method for the approach proposed in this study, particularly given its widespread availability and numerous implementations for energy data clustering [16]. However, its effectiveness is contingent on the assumption of spherical and equally variancelusters, which may not be suitable for cases involving irregularly shaped clusters.  
Note that the application of the \(K\)-means algorithm to a sample of \(n\) observed time series is based on the assumption that each time series of index \(i=1,\ldots,n\) is observed at the same time values of index \(j=1,\ldots,m\). This assumption limits the scope of the  
Figure 3: Collection and recording of hourly energy consumption data of nine IMMs into the SQL database for effective data management and analysis.  
approach because it may not account for time series sampled at different time indices in actual applications [31].  
A time series is represented by a generic point \(\mathbf{y}_{i}\in\mathbb{R}^{m}\) assigned to a group that should have high intracluster similarity (the sum of the squares within clusters, \(SSW\)) with the remaining points belonging to the same cluster, whereas it has low intercluster similarity (the sum of the squares between clusters, \(SSB\)) with the remaining points assigned to different groups. These two features are analytically expressed as \(SSW=\sum_{k=1}^{K}N_{k}\sum_{\mathbf{y}_{i}\in\mathcal{C}_{k}}d(\mathbf{y}_{i},\mathbf{ \varsigma}_{k})\) and \(SSB=\sum_{k=1}^{K}N_{k}\cdot d(\mathbf{\varsigma}_{k},\mathbf{\varepsilon})\), where \(d:\mathbb{R}^{m}\times\mathbb{R}^{m}\rightarrow[0,\infty)\) is the distance metric in \(\mathbb{R}^{m}\) (the Euclidean distance in this study).  
The sum of the squared distances between each data point \(\mathbf{y}_{i}\) and its corresponding closed centroid, denoted by \(\mathbf{\varsigma}_{k}\), is known as the within-cluster variance, \(SSW\). The closed centroid, \(\mathbf{\varsigma}_{k}\), is the barycenter of the \(k\)-th cluster, \(\mathcal{C}_{k}\), and is calculated as the average of all the data points in the cluster, \(\mathbf{y}_{i}\), divided by the number of data points in the cluster, \(|\mathcal{C}_{k}|\). The between-cluster variance \(SSB\) is the sum of the squared distances between the mean positions of all centroids \(\mathbf{\varepsilon}\) and the closed centroid \(\mathbf{\varsigma}_{k}\). The between-cluster variance, \(SSB\), represents the spread of data points across all clusters.  
The \(K\)-means algorithm aims to identify the cluster centers that minimize the SSW within clusters and maximize the SSB between clusters. To achieve this goal, the algorithm comprises two fundamental steps: (i) the uniform initialization of \(K\) centroids among the points to be classified and (ii) the subsequent aggregation of points around the centroids based on the distance criterion of similarity. The centroid is determined by averaging the points in each cluster, and this procedure is repeated for each cluster. The clusters and their respective centroids are then recalculated, and the process continues until the positions of the centroids exhibit minimal fluctuations, which is accomplished through the repetitive implementation of the previously mentioned steps.