# Committee Machine Learning for Electrofacies-Guided Well Placement and Oil Recovery Optimization
## 2 Data and Methodology
### Methods
#### 2.2.2 K-Medians Clustering  
The k-median clustering algorithm is a robust unsupervised learning technique designed to partition a dataset into \(k\) clusters while minimizing the sum of Manhattan distances (1-norm distances) between points and their respective cluster centers. Unlike k-means, which minimizes the squared Euclidean distances, k-median clustering uses the median of the points in each cluster as the cluster center. This makes it particularly effective for datasets with outliers or non-spherical clusters, as the median is less influenced by extreme values [32; 33]. This robustness has led to its application in areas such as geographic positioning, data mining, and classification [34].  
The algorithm operates by minimizing an objective function, defined as the sum of Manhattan distances between data points and their nearest cluster center:  
\[SSK_{med}=\sum_{k=1}^{K}\sum_{x\in C_{K}}||x_{i}-median(C_{k})||_{1} \tag{4}\]  
where \(C_{k}\) represents the set of points in cluster \(k\), and \(median(C_{k})\) is the median of the points in that cluster. This minimization ensures that the k-median algorithm is robust to the effects of outliers, as the median can only be significantly influenced if more than half the data points deviate from the majority [32; 33].  
The algorithm follows an iterative process. It begins with the initialization phase, where k initial cluster centers are selected, either randomly or through heuristic methods like coresets. Coresets are small, weighted subsets of the data that preserve clustering structure while reducing computational complexity, making them particularly effective for large datasets [34]. In the assignment step, each data point is assigned to the cluster with the closest center, minimizing the Manhattan distance:  
\[C_{k}=\Big{\{}x\in\mathfrak{R}^{d}:\big{|}\big{|}x_{i}-median(C_{k})\big{|} \big{|}\big{|}_{1}\leq\big{|}\big{|}x_{i}-median(C_{j})\big{|}\big{|}\big{|}_ {1},\forall j=1\
eq k\Big{\}} \tag{5}\]Next, in the update step, the median of the assigned points in each cluster is recalculated to serve as the new cluster center. This step is critical as it ensures that the objective function is progressively minimized:  
\[median(C_{k})=arg\ min\sum_{x\in C_{k}}||x_{i}-\text{m}||_{1} \tag{6}\]  
The iteration process continues until convergence, which occurs when the cluster centers stabilize, or the reduction in the objective function between successive iterations falls below a pre-specified threshold.  
K-median clustering proves to be particularly effective for datasets where the mean is susceptible to the influence of outliers, thus providing a more robust central tendency  
Figure 1: Workflow of the K-means clustering algorithm. Modified from [PERSON] et al., 2024 [13].  
measure for each cluster. This technique is a modification of k-means clustering, aimed at segmenting a dataset into k clusters. The selection of k is essential for shaping the resulting k-cluster model and is determined by user input. K-medians reduces the sensitivity of k-means to outliers by adopting an alternative dissimilarity metric, specifically the L1-norm, in place of the Euclidean distance.