# Concept Drift Adaptation with Incremental-Decremental SVM
## 4 Adaptive-Window Incremental-Decremental SVM (AIDSVM)
```
procedureAdaptiveShiftingWindow(data_stream) \(\triangleright\) the data stream is considered continuous choose \(C\), \(\epsilon_{cut}\) choose \(min\_window\_size\) and \(max\_window\_size\), with \(min\_window\_size<max\_window\_size\) set initial solutions using \((x_{1},y_{1})\) and \((x_{2},y_{2})\) \(\triangleright\) window initialized with empty list \(W\leftarrow\varnothing\) while incoming data samples exist do \((x_{k},y_{k})\leftarrow\) next incoming sample extend kernel with \((x_{k},y_{k})\) collect statistics for next vector \(x_{k}\) append vector \(x_{k}\) to window \(W\) Learn(\(x_{k}\)) ifsize(\(W\)) \(<min\_window\_size\)then continue for\(i\leftarrow\)\(min\_window\_size\) to size(\(W\)) \(-min\_window\_size\)do \(W_{0}\gets x_{1}\ldots x_{i}\) \(W_{1}\gets x_{i+1}\ldots x_{\text{size($W$)}}\) \(\mu_{0},\mu_{1}\leftarrow\text{mean}(W_{0}),\text{mean}(W_{1})\) if\(|\mu_{0}-\mu_{1}|\geq\epsilon_{cut\_adjusted}\) \(\text{\sc Unlearn}(\text{all}\ x_{j}\in W_{0})\) continue ifsize(\(window\)) \(>window\_size\)then \(\text{\sc Unlearn}(\text{first}\ x_{i}\in W)\) \(\triangleright\) remove first sample from window \(W\) procedureLearn(\(x_{c}\)) whilesample\(x_{c}\) not yet learned do \(Q\leftarrow\) compute_Q(kernel, y) with Equation (11) \(\beta_{s}\leftarrow\) compute_beta(Q, y) with Equation (12) \(\gamma_{s}\leftarrow\) compute_gamma(Q, y, \(\beta_{s}\)) with Equation (13) \(\Delta l_{s},\Delta l_{t}\leftarrow\) compute_limits_for_support_and_rest_vectors(\(x_{c}\), \(C\)) with Equation (14) update all \(\lambda_{s}\), \(\lambda_{c}\) using \(\Delta l_{s}\), \(\Delta l_{r}\), \(C\), \(\beta_{s}\) and \(\gamma_{s}\) \(\triangleright\) at least one vector will migrate reassign_vectors_in_sets() procedureUnlearn(\(x_{c}\)) while\(x_{c}\)not yet unlearned do if\(x_{c}\) removal leaves its class unrepresented then return \(Q\leftarrow\) compute_Q(kernel, y) with Equation (11) \(\beta_{s}\leftarrow\) compute_beta(Q, y) with Equation (12) \(\gamma_{s}\leftarrow\) compute_gamma(Q, y, \(\beta_{s}\)) with Equation (13) \(\Delta l_{s},\Delta l_{r}\leftarrow\) compute_limits_for_support_and_rest_vectors(\(x_{c}\), \(C\)) with Equation (14) update all \(\lambda_{s}\), \(\lambda_{c}\) using \(\Delta l_{s}\), \(\Delta l_{r}\), \(C\), \(\beta_{s}\) and \(\gamma_{s}\) \(\triangleright\) at least one vector will migrate reassign_vectors_in_sets()
```  
**Algorithm 1** Concept drift AIDSVM learning and unlearning  
``` procedureAdaptiveShiftingWindow(data_stream) \(\triangleright\) the data stream is considered continuous choose \(C\), \(\epsilon_{cut}\) choose \(min\_window\_size\) and \(max\_window\_size\), with \(min\_window\_size<max\_window\_size\) set initial solutions using \((x_{1},y_{1})\) and \((x_{2},y_{2})\) \(\triangleright\) window initialized with empty list \(W\leftarrow\varnothing\) while incoming data samples exist do \((x_{k},y_{k})\leftarrow\) next incoming sample  extend kernel with \((x_{k},y_{k})\) collect statistics for next vector \(x_{k}\) append vector \(x_{k}\) to window \(W\) Learn(\(x_{k}\)) ifsize(\(W\)) \(<min\_window\_size\)then continue for\(i\leftarrow\)\(min\_window\_size\) to size(\(W\)) \(W_{0}\gets x_{1}\ldots x_{i}\) \(W_{1}\gets x_{i+1}\ldots x_{i}\) \(\mu_{0},\mu_{1}\leftarrow\text{mean}(W_{0}),\text{mean}(W_{1})\) if\(|\mu_{0}-\mu_{1}|\geq\epsilon_{cut\_adjusted}\) \(\text{\sc Unlearn}(\text{all}\ x_{j}\in W_{0})\) continue ifsize(\(window\)) \(>window\_size\)then \(\text{\sc Unlearn}(\text{first}\ x_{i}\in W)\) \(\triangleright\) remove first sample from window \(W\) procedureLearn(\(x_{c}\)) whilesample\(x_{c}\) not yet learned do \(Q\leftarrow\) compute_Q(kernel, y) with Equation (11) \(\beta_{s}\leftarrow\) compute_beta(Q, y) with Equation (12) \(\gamma_{s}\leftarrow\) compute_gamma(Q, y, \(\beta_{s}\)) with Equation (13) \(\Delta l_{s},\Delta l_{t}\leftarrow\) compute_limits_for_support_and_rest_vectors(\(x_{c}\), \(C\)) with The SVM classifier, trained on the entire window \(W\), is evaluated on every sample \(x_{i}\in W\).