## 3 Macro SOStream Algorithm
Figure 2: Diagram of the Macro SOStream algorithm, where the representation (XX) indicates the steps cited from the text. In step 6, there is a check if \(v(t)\) is within the radius of the winner microcluster. If so, the winner microcluster has its centroid updated using the traditional arithmetic mean approach, step 7. The radius value will be the \(\eta\)-th distance between the winner and all its neighbors. The algorithm also updates the centroid of the winner's neighboring microclusters (step 8), bringing them closer together by the following equation:  
\[C_{i}(t+1)=C_{i}(t)+\alpha\beta(C_{win}(t)-C_{i}(t)). \tag{1}\]  
Here, \(\beta\) is defined by:  
\[\beta=e^{-\frac{d(C_{i}C_{win})}{2r_{win}^{2}}}. \tag{2}\]  
Moreover, \(\alpha\) is a hyperparameter; \(C_{win}\) and \(r_{win}\) are the centroid and radius of the winner microcluster. This technique, already present in SOStream, is inspired by updating weights for the winning neuron in a Self-Organizing Map (SOM), or Kohonen Network. For the case where \(v(t)\) does not belong to the winning microcluster, the distance between \(v(t)\) and the centroid of the winning microcluster will determine whether the sample belongs to \(Macro_{j}\), step 10. The equations that define the distance and threshold are as follows:  
\[d(v(t),C_{win})>p\cdot r_{win}. \tag{3}\]  
In this case, \(p\) is a hyperparameter, and \(d(v(t),C_{win})\) is the Euclidean distance between \(v(t)\) and the centroid of the winning microcluster \(C_{win}\). If Equation (3) is true, \(v(t)\) does not belong to the analyzed \(Macro_{j}\), step 11. The Macro SOStream verifies if \(v(t)\) belongs to existing macroclusters. If not, it creates a new macrocluster. Accordingly, the algorithm checks if there is another macrocluster (\(Macro_{j+1}\)) to analyze, as shown in step 12. If there is no \(Macro_{j+1}\), it creates the macrocluster \(Macro_{j+1}\) (step 14). Otherwise, it analyzes \(Macro_{j+1}\) in the same way as it did in \(Macro_{j}\), step 13. If the equations are not satisfied, \(Macro_{j}\) receives the new microcluster containing \(v(t)\), step 16. When it creates or updates a microcluster, the algorithm updates the number (\(n_{j}\)), the centroid (\(C_{j}\)), and the list of microclusters (\(micro_{j}\)) of the macrocluster. Then, a simple arithmetic mean is used to find the new centroid of the macrocluster. In step 9, the algorithm calculates the overlap after assigning \(v(t)\) to a microcluster using the following equation:  
\[d(Micro_{win},Micro_{i})-(r_{win}+r_{i})<0, \tag{4}\]  
where \(Micro_{win}\) and \(r_{win}\) are the winning microcluster and its radius, \(Micro_{i}\) represents all microclusters of the \(Macro_{j}\), and \(r_{i}\) is the radius of the other microclusters. In the next step of the algorithm, if the Equation (4) is true, then the following equation is verified:  
\[d(Micro_{win},Micro_{i})<\gamma, \tag{5}\]  
where \(\gamma\) is a hyperparameter, the merge threshold. Figure 3: Clustering process in Macro SOStream. (**a**) Macrocluster with arbitrary form. (**b**) Macroclusters with one and many microclusters. (**c**) Evolution of macroclusters over time. If Equation (5) is satisfied, the algorithm merges the overlapping microclusters by following the equations:  
\[r_{merged}=d(C_{a},C_{b})+max(r_{a},r_{b}), \tag{6}\]  
\[n_{merged}=n_{a}+n_{b}, \tag{7}\]  
Figure 2:0  
Then, Macro SOStream checks if there is more than one macrocluster, in step 17. If not, sample \(v(t+1)\) arrives for analysis, and the flow continues, going back to step 3. However, if so, the algorithm checks whether the existing macroclusters are overlapping, in step 18. For the overlap analysis of macroclusters in step 18, the algorithm uses the microcluster that received \(v(t)\). From there, it seeks the nearest microcluster that belongs to the other macroclusters. Therefore, the algorithm checks whether there is an overlap of the microclusters using Equations (4) and (5). Figure 4 illustrates three microclusters' and macroclusters' situations.