A sample implement of ID3 algorithm, based on a bird flu samples, coded by C++ 11.
The samples consist of seven records. Each record contains its conclusion whether having bir flu or not and the state of each possibly decisive feature.
All the records are shown by the following picture:
For easily access the records, we use integers to identify the state of features. Each integer has a different meaning, which can be found in the above picture.
The records are storaged in the file './source/samples.txt', which contains the following content:
headache courbature temperature hasBirdFlu
1 1 0 0
1 1 1 1
1 1 2 1
0 1 0 0
0 0 1 0
0 1 2 1
1 0 1 1
The following picture shows the process of running the program:
As you can see, some calculation process are displayed. Int the end, the program outputs the decision tree, which generated by the ID3 algorithm.