## 3 Methodology
### Building of Adaptive Classification Model
#### 3.2.2 VFDT Classifier Building  
It includes two types of nodes: decision nodes and terminal nodes; each terminal node in the tree stores enough statistical information about the characteristic value. The heuristic function uses this information to perform split testing. After reaching the new data instance, it starts to transfer from the root node (root) until it reaches a specific leaf node. At this point, if the class value of the new instance is not available (i.e., unknown value) or has not been seen before (i.e., a new class in multi-class classification tasks), the instance is classified according to the majority of the current terminal nodes. Otherwise, the statistical information is evaluated, and the evaluation of a new decision node can be created according to the following conditions.  
The evaluation includes computing the gain for all features in all possible split points. For each split point, the impurity of class distribution of the current node and the possible child nodes will be computed using Entropy, according to the following equation, for node a:  
\[\texttt{Entropy}(\texttt{a})=-\sum_{\texttt{i}=0}^{\texttt{c}-1}\texttt{p}( \texttt{i}|\texttt{a})\texttt{log}_{2}\texttt{p}(\texttt{i}|\texttt{a}), \tag{4}\]  
where c refers to the number of classes. The difference between the entropy of the current node and the average value of the entropy of its possible child nodes after splitting represents the gain of the splitting operation. A split that produces a more uniform class distribution, that is, a higher gain, is desirable. If the difference between the highest two features is greater than the Hoeffding boundary value, which is computed according to Equation (3), the current terminal node will be replaced with a decision node based on the highest feature. At the same time, for each split branch of this new node, a new empty terminal node will be added.  
The final decision of classifying the data instance will be made using majority voting among all the decision trees in the forest. If the instance is classified as a seizure, an immediate alert will be sent to the patient's device and also to the responsible medical staff. Algorithm 2 summarizes the steps of the building classifier stage.  
```
1:procedureAdaptiveClassifierBuilding
2:R \(\leftarrow\) preprocessedEEG stream samples
3:Trees \(\leftarrow\) Ensemble bagging model of VFDT trees
4:Wt: warning threshold
5:Dt: drift threshold
6:whileR has instance d do
7:X \(\leftarrow\) set of features values in d
8:y \(\leftarrow\) class label value in d
9:for each tree t in Trees do
10: Using X, Trace t until leaf node ln is reached
11:ifKnown(y) = False then
12:y \(\leftarrow\) major class(ln)
13:else
14:bf1,bf2 \(\leftarrow\) two highest gain features \(\triangleright\) based on Equation (4)
15:HB \(\leftarrow\) Hoeffiding Bound \(\triangleright\) based on Equation (3)
16:if Gain(bf1)-Gain(bf2) \(>\) HB then
17:Replace tn with a decision node based on split test of bf1
18:Add new terminal nodes for each possible split value
19:endif
20:endif
21:ifWarning(t,X,y) \(>\) Wt then
22:Make new background tree bt
23:endif
24:if Drift(t,X,y) \(>\) Dt then
25:Replace t with bt
26:endif
27:endfor
28:endwhile
29:Return Trees model, Classified sample instances
30:endprocedure
```  
**Algorithm 2** Adaptive Classification Model-Master Node.