# A Clustering Algorithm for Evolving Data Streams Using Temporal Spatial Hyper Cube
## 3 Methodology
### Developed Algorithms
#### 3.4.4 BOCEDS Micro-Cluster Update  
The goal of the micro-cluster update is to perform two functionalities: The first one is incrementing the number of points for T by 1 as it is shown in the Equation (7)  
\[\text{Local density, }N_{t+1}=N_{t}+1 \tag{3}\]  
the first one is to decide whether the newly arrived data point \(x_{i}\) will cause converting its target T to a CMC. This is accomplished when the condition in Algorithm 4 line 3 is satisfied. In this case, then the radius will be updated and the energy will be assigned to 1 as it is shown in lines 5 and 6 as it is shown in Equation (8):  
\[\text{Radius, }R_{t+1}=min\bigg{(}\bigg{[}R_{t}+\bigg{\{}\frac{2\times d(X_{t+1},C_ {t})}{R_{t}}-1\bigg{\}}\times\frac{1}{\text{Decay}}\bigg{]},R_{max}\bigg{)} \tag{4}\]```
Input: (1) \(X_{i}\): Data point (2) CMCs: core micro-cluster set (3) PMCs: potential micro-cluster set (4) WMCs: weak micro-cluster set Output: T: the Micro-cluster that contains \(X_{i}\). 1- start algorithm 2- initialization: \(T\leftarrow\)[] 3- Find a weak micro-cluster \(Q\) that satisfied Equation (2). 4- if\(Q\) not empty then 5- \(T\gets Q\)  Go to Ret 6- end if 7- Find a potential micro-cluster \(Q\) that satisfied Equation (2). 8- if\(Q\) not empty then 9- \(T\gets Q\)  Go to Ret 10- end if 11- Find a core micro-cluster \(Q\) that satisfied Equation (2). 12- if\(Q\) not empty then 13- \(T\gets Q\)  Go to Ret 14- end if 15- Ret:Return \(T\) 16- end algorithm
```

**Algorithm 3**BOCEDS Micro-Cluster Searching

On the other side, when the data point already belongs to MC then the radius and the energy will be updated as it is shown in Algorithm 6 lines 8 and 9 as it is shown in Equation (9):

\[\text{Energy, }E_{t+1}=E_{t}+\left\{\frac{R_{t}-d(X_{t+1},C_{t})}{R_{t}} \right\}\times\frac{1}{\text{Decay}} \tag{5}\]

The last thing to do is to check whether the data point belongs to the shell as it is given in Algorithm 6 line 12. In this case, the number of points in the shell, as well as the center, are updated using Equations (10) and (11). \[N_{t+1}^{\prime}=N_{t}^{\prime}+1 \tag{6}\]

\[\text{Center, }C_{t+1}^{k}=\frac{\left(N_{t+1}^{\prime}-1\right)\times C_{t}^{k }+X_{t+1}^{k}}{N_{t+1}^{\prime}} \tag{7}\]

The output of the algorithm is an updated CMC, PMC, or WMC. The next stage is to check whether moving micro-clusters from one buffer to another is needed. This is given in the next sub-section. #### 3.4.5 BOCEDS Moving Weak Micro-Clusters to a Buffer

The pseudocode of converting weak micro-cluster is presented in Algorithm 5. As it is shown, it accepts the two types of micro-cluster, namely, CMCs and WMCs in addition to decay. The output is the update of each CMC and WMC. The pseudocode starts with the energy of all CMCs with the value of \(\frac{1}{Decay}\). Afterwards, for each T in CMCs, the energy is checked whenever the energy is lower than 0, and T will be removed from all CMCs and added to WMCs. When T is removed from CMCs, it is energy is set to 0.5. The next step after converting the CMCs to WMCs is to check inside WMCs and PMCs for an update on micro-cluster removal which is provided in the next sub-section. ```
Input: (1) \(X_{i}\): Data point (2) CMCs: core micro-cluster set (3)PMCs: potential micro-cluster set (4) WMCs: weak micro-cluster set (5) \(T\): the Micro-cluster that contains \(X_{i}\) Output: (1) CMCs:core micro-cluster set (2) PMCs:potential micro-cluster set (3) WMCs:weak micro-cluster set 1- start algorithm 2- Update the local density (\(N_{l}\)) of \(T\) using Equation (3). if\([\)\(T\in PMCs\)\(\wedge\)\((N_{t+1}=Th_{density})]\)\(\vee\)\((T\in WMCs\)\()\)then
4- CMCs=CMCs U T 5- Update the radius (\(R_{t+1}\)) of the micro-cluster (\(T\)) using Equation (4). \(E_{t+1}\gets 1\) 7- else if\(T\in MC\) core then
8- Update the radius (\(R_{t+1}\)) of the micro-cluster (\(T\)) using Equation (4). Update the energy (\(E_{t+1}\)) of the micro-cluster (\(T\)) using Equation (5).