## 3 The Proposed HSDW-MI Algorithm
### Two Phases of the HSDW-MI Algorithm
#### 3.2.2 Dynamic Weighting Phase of HSDW-MI Algorithm  
In the dynamic weighting phase, a dynamic weighting method based on G-mean values is proposed. The G-mean value of each classifier in the ensemble on the current chunk is used as the weight of each base classifier in the ensemble. As the data chunk develops, if the weight of the current classifier is not lower than the threshold set by the user it will be directly added to the ensemble, otherwise the current base classifier will be removed. The classifiers in the ensemble are always in a dynamic updating process as a way to accommodate class imbalance and concept drift. The HSDW-MI algorithm trains a base classifier \(C^{t}\) on the balanced data chunk \(D^{{}^{\prime}}_{t}\) obtained after hybrid sampling and adds it to the current ensemble \(E^{t}\), denoted as \(E^{t}=\left\{C^{t}_{1},C^{t}_{2},\ldots,C^{t}_{n^{\prime}}\right\}\). Then, the weights \(w^{t}=\left\{w^{t}_{1},w^{t}_{2},\ldots,w^{t}_{n^{\prime}}\right\}\) of the base classifiers in the ensemble are updated on the current data chunk. The weights represent the adaptation of the base classifiers to the current data chunk and indicate the importance of the base classifiers. To better accommodate class imbalance and concept drift in data streams, as well as to improve the classification capability of the ensemble, this section uses the G-mean value as the formula for the base classifier weights. G-mean is a common metric for algorithm performance evaluation in the imbalance field. Compared with other metrics, G-mean is more concerned with the classification performance of minority class, and it indicates a poor classification of minority class samples when the G-mean value is low [32]. The formulas for G-mean and as base classifier weights are shown in Equations (8) and (9), respectively. \[GM^{t}=\left(\prod_{i=1}^{n}\frac{TP_{i}}{TP_{i}+FP_{i}}\right)^{\frac{1}{2}} \tag{8}\]  
\[w^{t}_{j}=GM^{t}_{j}\times w^{t-1}_{j} \tag{9}\]  
where \(w^{t}_{j}\) is denoted as the weight of the base classifier \(C^{t}_{j}(j\in\{1,\ldots,L\})\) on the data chunk \(D^{{}^{\prime}}_{t}\), and \(w^{t-1}_{j}\) is the weight of the base classifier \(C^{t}_{j}\) on the previous data chunk. The weights of the base classifier on the previous data chunk \(D^{{}^{\prime}}_{t-1}\) are added with the aim of decreasing the weights of the base classifier over time, thus reducing the influence of the ensemble on previous concepts and improving the adaptability of the ensemble to new concepts. When the updated weight of the base classifier in the ensemble is below the set threshold \(\theta\), the base classifier will be removed. If a classifier is deleted, on the one hand, it may be because the classifier is created too early and no longer fits the current data concept, and, thus, the weight is reduced. On the other hand, a concept drift may have occurred in the current chunk, which causes a dramatic decrease in the classifier's performance. Ensemble \(E\) uses Equation (10) to predict the classification result of instance \(x_{i}\) in data chunk \(D^{{}^{\prime}}_{t}\), where \(sign(\cdot)\) is the sign function. \[\overset{\wedge}{y}_{j}=sign\left(\sum_{j=1}^{m}w^{t}_{j}C^{t}_{j}(x_{i})\right) \tag{10}\]  
The pseudo code of the dynamic weighting phase of the HSDW-MI algorithm is shown in Algorithm 2. ```
Input: Data stream \(S=\{D_{1},\ldots,D_{t-1},D_{1}\}\), Data chunk \(D_{t}=<x_{i}\), \(y_{i}>\), Ensemble \(E=\{C_{1},C_{2},\ldots,C_{n}\}\) Ensemble size \(L\), Update threshold \(\theta\). Output: Ensemble \(E=\{C_{1},C_{2},\ldots,C_{n}\}\), Predicted label \(\overset{\wedge}{y}\).