| Algorithm 2 Generating decision tree. |
|
Input:D: the training set; C: the attribute set. Output: A decision tree Function TreeGenerate 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 from C 9: for each do 10: add a branch below N, corresponding to 11: is the subset of D with 12: if 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 as the branch node 16: end if 17: end for |