## 3 Modified SOSK-Means
### Modification in the K-Means Phase  
The modification effected in the K-means phase of the improved SOSK-means algorithm addressed the misleading effects of outliers in the dataset, which usually affect the standard K-means algorithm at the centroids update stage. The use of the 'average' as the statistic for calculating the new cluster centroid was sensitive to outliers [3]. According to [58; 59], K-means assume Gaussian data distribution, being an instance of the Gaussian mixture model. As such, about 99.73% of the data points within a cluster record point-to-centroid distances of three standard deviations (\(\sigma\)) from the cluster centroid. Therefore, any point with a point-to-centroid distance that is outside this range with respect to its cluster is considered an outlier. Subsequently, it is excluded in the computation of the centroid update. According to [59], a standard deviation (\(\sigma\)) was taken to be 1.4826 of the median absolute deviation (\(MAD\)) for population distribution. The median absolute deviation gave a robust statistical dispersion measure and was more resilient to outliers than the standard deviation [60]. Given a point-to-centroid distance threshold \(T_{ptc}\):  
\[\sigma=1.4826 MAD_{ci} \tag{28}\]  
\[MAD_{ci}=median|ci-median(ci)| \tag{29}\]  
\[T_{ptc}=3\sigma\]  
\[\therefore\ T_{ptc}=3(1.4826 MAD_{ci})\]  
\[\therefore\ T_{ptc}=4.4478 MAD_{ci} \tag{30}\]  
The centroid update was calculated using Equation (31) in the classical K-means:  
\[\mu_{i}^{(it+1)}=\frac{1}{\left|C_{i}^{(it)}\right|}\ \sum_{x_{j}e_{i}}x_{j} \tag{31}\]  
However, in the improved SOSK-means, \(T_{ptc}\) was introduced for outlier detection and exclusion in the new centroid update using Equation (32):  
\[\mu_{i}^{(it+1)}=\frac{1}{\left|C_{i}^{(it)}\right|-\left|C_{io}^{(it)}\right| }\ \sum_{x_{j}e_{i}}x_{j}\ :x_{j}=0\ if\ ||x-\mu_{i}||\ >T_{ptc} \tag{32}\]  
where \(C_{io}^{(it)}\ e\ C_{i}^{(it)}\) represents the sets of points \(x_{j}\) assigned to cluster \(C_{i}^{(it)}\) which has a point-to-centroid distance of \(||x-\mu_{i}||>T_{ptc}\). The main difference between Equations (31) and (32) is that in the latter equation, the sets of points assigned to a cluster with a point-to-centroid distance greater than thrice the standard deviation (\(3\sigma\)) were excluded from the centroid update calculation. This excluded the outliers from contributing to the mean square error that was being minimized. Algorithm 2 presents the pseudocode for the proposed improved SOSK-means algorithm. ```
**Algorithm 2** The proposed improved SOSK-means Pseudocode
``` Eco_size: population size ULSS: Upper limit for search space Max_iter: maximum number of iterations LDSS: Lower limit for search space PDim: problem dimension ObjFn(X): fitness (objective) function Optimal Solution  
```
1: Create an initial population of organisms \(X=\ (X_{1},X_{2},\ldots,X_{cosize})\)
2: Calculate the fitness of each organism
3: Keep the initial population's best solution BestX
4: Keep the initial population's maximum solution \(X_{max}\)
5:while\(iter\ \leq\) Max_iter
6:for\(i=1\ to\ Eco_size\)do
7:// 1 st Phase: Mutualism //
8: Select index \(j\ (1\ \leq j\leq Eco_size;j\
eq i)\) randomly
9: Select index \(k\ (1\ \leq k\leq Eco_size;k\
eq i;k\
eq j)\) randomly
10:\(rand_{1}=\ (1\ +round(rand(0,1)))\)
11:\(rand_{2}=\ (1\ +round(rand(0,1)))\)
12:if\(rand_{1}<\ rand_{2}\)
13:\(X_{mutual}=\left(\frac{X_{i}+X_{j}}{2}\right)\)
14:\(SaBF_{1}=\ (1\ +round(rand(0,1))\. *\ (ObjFn(X_{i})/(X_{max}))\)
15:\(SaBF_{2}=\ \left(1\ +round\big{(}rand(0,1)\big{)}\. *\ (ObjFn(X_{j})\ /(X_{max})\right)\)
16:\(RWRC=\ (1\ -0.5*\ round(rand(0,1))\)
17:for\(n=1\ to\ PDim\)do
18:\(X_{ineu}=X_{i}+(RWRC\. *\ (X_{best}-(\ X_{mutual}*SaBF_{1})))\)
19:\(X_{ineu}=X_{j}+(RWRC\.