Skip to main content
. 2020 May 6;22(5):527. doi: 10.3390/e22050527
Algorithm 2 Generating decision tree.

Input:D: the training set; C: the attribute set.

Output: A decision tree

Function TreeGenerate (D,C)

1: Create a node N

2: if tuples in D belong to only one class C then

3:  label N as a leaf node with class C; return

4: end if

5: if C is empty OR the samples of D are of the same class then

6:  set label N as the leaf node with the most common class in D; return

7: end if

8: Find the best splitting criterion c* from C

9: for each c* do

10:  add a branch below N, corresponding to c*=c*v

11:  Dv is the subset of D with c*=c*v

12:   if Dv is empty then

13:   label the branch node as the leaf node with the most common class in D; return

14:   else

15:   set TreeGenerate (Dv,Cc*) as the branch node

16:   end if

17: end for