# Committee Machine Learning for Electrofacies-Guided Well Placement and Oil Recovery Optimization
## 2 Data and Methodology
### Methods
#### 2.2.1 K-Means Clustering  
The k-means clustering algorithm is a widely used unsupervised learning technique designed to partition a dataset into \(k\) clusters, where \(k\) is a predefined number. The algorithm seeks to minimize the within-cluster sum of squared errors (SSE), which measures the compactness of clusters.  
\[SSE=\sum_{k=1}^{K}\sum_{x\in C_{k}}\big{|}\big{|}x-\mu_{k}\big{|}\big{|}^{2} \tag{1}\]  
where \(C_{k}\) represents the set of points in cluster \(k\), \(\mu_{k}\) is the centroid of cluster \(k\), and \(\big{|}\big{|}x-\mu_{k}\big{|}\big{|}^{2}\) denotes the Euclidean distance between a point \(x\) and the cluster centroid \(\mu_{k}\)[23; 24].  
The process begins with the initialization phase, where k initial cluster centers (centroids) are selected. Typically, centroids are chosen randomly, although more sophisticated methods like k-means++ or other probabilistic strategies can improve initialization by reducing sensitivity to starting conditions [25; 26].  
Once initialized, the algorithm iterates through two primary steps. In the assignment step, each data point is allocated to the cluster whose centroid minimizes the distance metric, often Euclidean distance [24; 27].  
\[C_{k}=\Big{\{}x\in\Re^{d}:\big{|}\big{|}x-\mu_{k}\big{|}\big{|}^{2}\leq\big{|} \big{|}x-\mu_{j}\big{|}\big{|}^{2},\forall j=1,\ldots,K\Big{\}} \tag{2}\]  
In the update step, the centroid of each cluster is recomputed as the mean of the points assigned to that cluster:  
\[\mu_{k}=\frac{1}{|C_{k}|}\big{|}\sum_{x\in C_{k}}x \tag{3}\]  
These steps are repeated until convergence, which occurs when centroids stabilize or a predefined stopping criterion, such as a maximum number of iterations, is met [23; 24].  
Despite its simplicity and computational efficiency, k-means has notable limitations. The algorithm is sensitive to the choice of initial centroids, which can lead to convergence at suboptimal local minima. To address this, methods like k-means++ select initial centroids probabilistically, ensuring better initial separation between clusters [25; 28]. Other strategies, such as hierarchical approaches that begin with a larger number of clusters and merge them iteratively, have been developed to improve initialization and cluster quality [26]. Furthermore, variants like MinMax k-means and density-based initializations seek to address the challenges of unbalanced cluster sizes and non-spherical data distributions [26; 29].  
Another critical limitation of the k-means algorithm is the assumption of spherical clusters and equal cluster sizes, which may not hold in real-world datasets. Additionally, the algorithm is sensitive to outliers, which can significantly distort centroid positions [27; 30]. Recent advances include stability-based methods for selecting the optimal number of clusters and pruning strategies to reduce computational overhead by narrowing the search space during iterations [26; 31].  
The K-means clustering algorithm is employed to derive significant clusters from large datasets. The algorithm's goal is to minimize the objective function associated with the squared distances between clusters. This optimization process allows for the identification of natural groupings or patterns within the data, based on the relationships among the variables. By utilizing the K-means clustering algorithm, it is feasible to categorize intricate datasets according to the underlying relationships present among the variables. This clustering methodology is particularly advantageous for uncovering hidden structures and patterns that may not be immediately visible through manual analysis. Figure 1 shows the k-means clustering algorithm workflow.