# A Clustering Algorithm for Evolving Data Streams Using Temporal Spatial Hyper Cube
## 3 Methodology
### Developed Algorithms
#### 3.4.4 BOCEDS Micro-Cluster Update
endif
11- \(d\leftarrow\) distance (\(X_{i}\), T.Center)
12- If\(\frac{R_{t+1}}{2}<d\leq R_{t+1}\), then
13- Update the number of data points in the shell region (\(N_{t+1}\)) of the micro-cluster (\(T\)) using Equation (10). 14- Update the center (\(C_{t+1}\)) of the micro-cluster (\(T\)) using Equation (7). 15- Update Cluster Graph using Algorithm 5 16- endif
17- end algorithm
```

**Algorithm 4**BOCEDS Micro-Cluster Update

#### 3.4.6 BOCEDS Micro-Cluster Removal

The pseudocode of micro-cluster removal is presented in Algorithm 6. The inputs are PMCs, WMCs, and decay, and the output is PMCs and WMCs. The algorithm starts by reducing the energy with the value o \(\frac{1}{Decay}\) for all micro-clusters inside WMCs. Next, for each micro-cluster in WMCs, the energy is checked and when it is lower than 0 the micro-cluster is removed from WMCs. In addition, the energy of all micro-clusters inside PMCs is checked and when it reaches the value of 0 or lower, then the micro-cluster is removed. ```
Input: (1) PMCs: core micro-cluster set (2) WMCs: weak micro-cluster set (3) Decay: the decaying period Output: (1) CMCs: core micro-cluster set (2) WMCs: weak micro-cluster set 1- start algorithm 2- Reduce an energy of \(\frac{1}{Decay}\) from all CMCs 3- for each T in CMCs do 4- if T.Energy \(\leq\) 0 then 5- T.Edges \(\leftarrow\) [] 6- remove T from all CMCs edges T.M \(\leftarrow\) 0 7- Remove T from CMCs T.Energy \(\leftarrow\) 0.5 8- WMCs = WMCs U T 9- end if 10- end for 11- end algorithm
```

**Algorithm 5** BOCEDS Moving Weak Micro-Clusters to A Buffer

```
Input: (1) PMCs: potential micro-cluster set (2) WMCs: weak micro-cluster set (3) Decay: the decaying period Output: (1) PMCs: potential micro-cluster set (2) WMCs: weak micro-cluster set 1- start algorithm 2- Reduce an energy of \(\frac{1}{Decay}\) from all WMCs 3- for each W in WMCs do 4- if T.Energy \(\leq\) 0 then 5- Remove W from WMCs 6- end if 7- end for 8- Reduce an energy of \(\frac{1}{Decay}\) from all PMCs 9- for each P in PMCs do 10- if T.Energy \(\leq\) 0 then 11- Remove P from PMCs 12- end if 13- end for 14- end algorithm
```

**Algorithm 6** BOCEDS Micro-Clusters Removal

#### 3.4.7 BOCEDS Update Cluster Graph

The update of a micro-cluster graph is based on checking the intersecting distance between the micro-clusters. Next, the value of the intersecting distance \(d^{\prime}\) which is calculated based on the radius \(R\) and \(R^{\prime}\) of the two micro-clusters using Equation (12) is compared with the distance between them \(d\) and when the distance \(d^{\prime}\) is lower than \(d\) then an edge is added between them and the graph is updated as it is shown in the pseudocode in Algorithm 7. \[d^{\prime}= \begin{cases}R+\frac{R}{2}^{\prime}&\text{, if }R\geq R^{\prime}\\ R^{\prime}+\frac{R}{2}&\text{, if }R^{\prime}>R\end{cases}  \tag{8}\]

## 4 Results and Discussions

The developed clustering algorithm is implemented using MATLAB R2021a. A series of experiments have been executed on five datasets including two real and three synthetic datasets to measure the performance of the developed BOCDES-TSHC algorithm and compare it with four benchmark clustering algorithms. The characteristics of the datasets used in the experiments are as detailed below in Table 2. Every experiment was repeated five times using different data points every time. The performance of the developed BOCDES-TSHC algorithm is evaluated using two types of evaluation namely, quality and efficiency. Quality evaluation includes (anomaly detection ratio, rand index, adjusted rand index, and normalized mutual information) and efficiency evaluation includes (memory usage and computational cost).