# An Adaptive Active Learning Method for Multiclass Imbalanced Data Streams with Concept Drift
## 3 The Proposed AdaAL-MID Algorithm
### Uncertainty Strategy Based on Dual-Margin Dynamic Threshold Matrix
Initially, each element of \(M_{1}\) is set to \(\theta_{1}\), and each element of \(M_{2}\) is set to \(\theta_{2}\). During the label request process, the marginal values \(margin_{min}\) and \(margin_{max}\) of instances are compared with the corresponding thresholds in \(M_{1}\) and \(M_{2}\), respectively, to select instances with greater information content. Furthermore, to emphasize the learning rate of instances during concept drift, the comparison process considers not only theoriginal elements of \(M_{1}\) and \(M_{2}\) but also the label budget. The dynamic thresholds used for comparison in \(M_{1}\) and \(M_{2}\) are calculated as shown in Equation (5). During the stable phase of the data stream (i.e., \(budget=\text{B}\)), the original thresholds are used. When a drift warning or confirmation occurs in the data stream, the thresholds are raised to increase the learning opportunities for new concept instances. \[dm_{1}=M[y_{1}][y_{2}]+budget-\text{B},\quad dm_{2}=M[y_{1}][y_{\min}]+budget- \text{B} \tag{5}\]  
Algorithm 1 shows the pseudocode of the proposed uncertainty strategy. For a new incoming instance, \(x\), the ensemble, \(E\), is first used for prediction (line 1), where \(y_{\text{c1}}\) represents the class with the highest probability in the ensemble prediction, \(y_{\text{c2}}\) is the second highest probability class, and \(y_{\min}\) is the least probable class. Then, the minimum margin, \(margin_{min}(x)\), and maximum margin, \(margin_{max}(x)\), of \(x\) are calculated, and the dynamic thresholds \(dm_{1}\) and \(dm_{2}\), used for comparison, are obtained through Equation (5) (lines 2-4). If \(margin_{min}(x)\) is less than \(dm_{1}\) or \(margin_{max}(x)\) is less than \(dm_{2}\), this indicates that the ensemble cannot predict the class of \(x\) with certainty. Therefore, the true label of \(x\) is requested, and the corresponding elements of the dual-margin threshold matrix are adjusted based on the prediction result of \(x\). The adjustment process is as follows (lines 8-19). ```
Input ensemble classifier \(E\), processed instance \(x\), current class distribution \(cd[\text{C}]\), minimum margin threshold matrix \(M_{1}\), and maximum margin threshold matrix \(M_{2}\). Output:\(labeling\in\{\text{true},\text{false}\}\) // request label? Process:
1. Make predictions on \(x\) by \(E\). 2. Calculate \(margin_{\min}(x)=r^{E}(y_{\text{c1}}\left|x\right. )-p^{E}(y_{\text{c2}}\left|x \right.)\). 3. Calculate \(margin_{\max}(x)=p^{E}(y_{\text{c1}}\left|x\right. )-p^{E}(y_{\min}\left|x \right.)\). 4. Calculate dynamic thresholds \(dm_{1}\) and \(dm_{2}\) using Equation (5). 5. if(\(margin_{\min}(x)\leq dm_{1}\mid margin_{\max}(x)\leq dm_{2}\)) then //meeting the uncertainty strategy
6. labeling = true. 7. Get real label \(y\) of \(x\) and calculate \(imb_{y}\) using Equation (4). 8. if(\(y\)=\(y_{\text{c1}}\)) then
9. \(M_{1}[y_{\text{c1}}\left|y_{\text{c2}}\right. )=M_{1}[y_{\text{c1}}\left|y_{ \text{c2}}\right. )\times(1-\beta\times margin_{\min}(x))\). 10. \(M_{2}[y_{\text{c1}}\left|y_{\min}\right. )=M_{2}[y_{\text{c1}}\left|y_{\min} \right. )\times(1-\beta\times margin_{\max}(x))\). 11. if(\(imb_{y}>1\)) then
12. \(M_{1}[y_{\text{c1}}\left|y_{\text{c2}}\right. )=M_{1}[y_{\text{c1}}\left|y_{ \text{c2}}\right. )\times(1-\beta\times margin_{\min}(x))\). 13. \(M_{2}[y_{\text{c1}}\left|y_{\text{c2}}\right. )=M_{2}[y_{\text{c1}}\left|y_{ \min}\right. )\times(1-\beta\times margin_{\max}(x))\). 14. elseif(\(y\)=\(y\)=\(y_{\text{c2}}\)&&\(imb_{y}>1\))then
15. \(M_{1}[y_{\text{c1}}\left|y_{\text{c2}}\right. )=M_{1}[y_{\text{c1}}\left|y_{ \text{c2}}\right. )\times(1-\beta\times margin_{\min}(x))\). 16. \(M_{2}[y_{\text{c1}}\left|y_{\text{min}}\right. )=M_{2}[y_{\text{c1}}\left|y_{ \text{min}}\right. )\times(1-\beta\times margin_{\max}(x))\). 17. else
18. \(M_{1}[y_{\text{c1}}\left|y_{\text{c2}}\right. )=M_{1}[y_{\text{c1}}\left|y_{ \text{c2}}\right. )\times(1+\beta\times margin_{\min}(x))\). 19. \(M_{2}[y_{\text{c1}}\left|y_{\min}\right. )=M_{2}[y_{\text{c1}}\left|y_{\min} \right.