|
Algorithm 1 C4.5 algorithm for arrhythmia learning. |
-
1:
function
DecisionTree(D, A, T) ▷ D: training dataset, A: feature set, T: decision tree
-
2:
if
D contains only training examples of the same heartbeat type
then
-
3:
Make T a leaf node labeled with heartbeat type ; ▷ C: heartbeat types
-
4:
else if
then
-
5:
Make T a leaf node labeled with heartbeat type , which is the most frequent heartbeat type in D;
-
6:
else ▷ D contains examples belonging to a mixture of heartbeat types
-
7:
=impurityEval-; ▷ We select a single feature to partition D into subsets so that each subset purer
-
8:
for Each feature
do
-
9:
=impurityEval-;
-
10:
end for
-
11:
Select that provides the biggest impurity reduction, computed using ;
-
12:
if
then ▷ does not significantly reduce impurity
-
13:
Make T a leaf node labeled with , the most frequent heartbeat type in D;
-
14:
else ▷ is able to reduce impurity
-
15:
Make T a decision node on ;
-
16:
Let the possible values of be . Partition D into m disjoint subsets based on the m values of ;
-
17:
for Each
do
-
18:
if
then
-
19:
Create a branch (edge) node for as a child node of T;
-
20:
DecisionTree;
-
21:
end if
-
22:
end for
-
23:
end if
-
24:
end if
-
25:
end function
|