# Detecting IoT Anomalies Using Fuzzy Subspace Clustering Algorithms
## 3 Proposed Methods
### Gustafson-Kessel (GK) Algorithm [42; 47]
Initialize \(U=U^{(0)}\)// \(U^{(0)}\in F_{fc}\) step \(1\) compute cluster mean \(v_{i}\) step \(2\) calculate the distance measure using Equation (18) step \(3\) calculate \(A_{\rm i}\) step \(3\) calculate the value of the membership data function using equation (21) and update \(U\), the partition matrix until \(1\mid U^{(0)}\)-\(U^{(-1)}\mid 1<\phi\)
```
**Algorithm 4** (GG)

### Mahalanobis Distance-Based Fuzzy C-Means algorithm (M-FCM) [47]

The objective function of the M-FCM algorithm is given by

\[J\big{(}X;\mathbf{U},V,\sum\big{)}=\sum_{i=}^{c}\sum_{k=1}^{N}(\mathbf{\mu}_{ik})^{m}D _{ik}^{2} \tag{23}\]

such that

\[J(X;U,V,\left\{A_{i}\right\})=\sum_{i=1}^{c}\sum_{k=1}^{N}(\mu_{ik})^{m}D_{ikA_ {i}}^{2} \tag{15}\]0 \[J(X;U,V,\left\{A_{i}\right\})=\sum_{i=1}^{c}\sum_{k=1}^{N}(\mu_{ik})^{m}D_{ikA_ {i}}^{2} \tag{15}\]1

\[D_{ik}^{2}=\left\{ \begin{pmatrix}x_{k}-v_{i})^{T}\sum_{i}^{-1}(x_{k}-v_{i})- ln\Big{|}\sum_{i=1}^{-1}\Big{|}\textit{if}\big{(}x_{k}-v_{i})^{T}\sum_{i}^{-1}(x_{k}-v_{i})- ln\Big{|}\sum_{i}^{-1}\Big{|}\geq\mathbf{0}\\ \mathbf{0}\textit{if}\big{(}x_{k}-v_{i})^{T}\sum_{i}^{-1}(x_{k}-v_{i})-ln\Big{|} \sum_{i}^{-1}\Big{|}<\mathbf{0}\end{pmatrix} \right\} \tag{25}\]Minimizing (23) with respect to all of its parameters subject to the constraints of (24) and (25) yields the M-FCM algorithm (Algorithm 5). ```
Given dataset X, choose the number of cluster c, (2 \(<\) c \(<\) N), weighting exponent m \(\in\)[0, \(\infty\)), iteration stop threshold \(\phi\) > 0. Initialize randomly partition matrix (membership matrix) U subject to the constraint (24), iteration counter l = 1. step 1 Evaluate or update cluster-centroid v; i = 1, 2,..., c. step 2 Evaluate pseudo-inverse matrix of covariance \(\sum_{i}^{-1}\) Step 3 Evaluate \(\mathbf{D}_{i\mathbf{k}\mathcal{L}}^{2}\) using (25) Step 4 Evaluate the value of the objective function (I) using (23) Step 5 Set l = 1 + 1 to update objective function J Step 6 If the value of the objective function obtained in step 3 satisfies \(\left\|\boldsymbol{I}^{I}-\boldsymbol{J}^{I-1}\right\|<\emptyset\), stop Output cluster set and membership matrix Step 7 Else go to step 1
```

**Algorithm 5** (M-FCM)

### Common Mahalanobis Distance-Based Fuzzy C-Means algorithm (CM-FCM) [47]

In this algorithm, all of the covariance matrices (\(\sum_{i}\)) of the objective function are replaced with a common covariance matrix (\(\sum\)). The objective function of CM-FCM is given as follows:

\[\boldsymbol{J}(\boldsymbol{X};\boldsymbol{U},\boldsymbol{V},\sum)=\sum_{i= \boldsymbol{k}=\boldsymbol{1}}^{\boldsymbol{c}}\sum_{\boldsymbol{k}=\boldsymbol {1}}



The above Figure depicts a concise view of the NT-FCM clustering algorithm. It has the following main components. First of all, the method computes CORE, a lower dimensional space of the dataset by generating nano topology and basis. Then, the steps of FCM like initialization, membership assignment, cluster-center update, convergence check, iteration counter update, and finally stopping criteria check are executed. It illustrates the iterative process of adjusting cluster memberships and updating cluster centers until convergence is achieved in a lower dimensional space. This method supplies a set of fuzzy clusters in the lower dimensional space. A flowchart of the nano topology-based GK clustering algorithm is given in Figure 2 below. Figure 2 illustrates the iterative process of NT-GK clustering algorithm. It is an extension of the NT-FCM clustering algorithm where an adaptive distance norm was used to detect clusters of various shapes from one dataset. All other steps are similar to Figure 1. Each cluster has its own norm-inducing matrix. The method supplies a set of fuzzy clusters in the lower dimensional space. A flowchart of the nano topology-based GG clustering algorithm is given in Figure 3 below. Figure 3 illustrates the iterative process of the NT-GG clustering algorithm.