1. Input: Root node of a RLID3 decision tree, Incremental data set 2. Output: adjusted decision tree 3. declare a variable curNode, decision tree is used to represent the nodes in the traversal algorithm 4. set the curNode to the root node of the input RLID3 decision tree 5. adding the incremental data set to the sample feature code of the curNode 6. if (The classification of each sample is the same in the sample feature code set of the curNode) {//All samples are divided into similar 7. curNode is set to a leaf node, namely: the curNode attribute is set to null 8. class attribute value of curNode is set to the classification of the sample feature code set of the curNode 9. }else{//The samples belong to the category is not exactly the same 10. if (curNode is a leaf node) {//The attribute of the curNode is null 11. using the feature sample code set of the curNode, according to the formula (1), choosing the attribute with the maximum value of decision tree optimization ratio, the attribute of the curNode is set to the attribute 12. if (decision tree optimization ratio of the attribute of the curNode is 0) { 13. set the curNode to the leaf node, namely: the attribute of the curNode is set to null 14. class attribute value of the curNode is set to the most class of sample feature code set 15. }else{//The maximum value of decision tree optimization ratio is not 0 16. the attribute of the curNode as the attribute of the root node, call the RLID3 algorithm makeRLID3Tree (Sample feature set of the curNode, the attribute of the curNode) to build RLID3 tree} 17. }else{//the curNode is a branch node 18. using sample feature set of the curNode. According to the formula (1), selecting the attribute of the maximum value of decision tree optimization ratio, denoted as A 19. if(decision tree optimization ratio of A is 0){// 20. the curNode is set to leaf node 21. class attribute value of the curNode is set to the highest value in sample feature code set of the curNode 22. }else{//decision tree optimization ratio of A is not 0 23. The attribute of the curNodeis the same as A. 24. while(sample:sample feature code set of the curNode){ 25. add sample to the childrenTrainData[sample partition attribute's value number] array 26. } 27. for (j = 0; j< the number of the curNode’s available; j++) 28. the node that corresponds to the first j value is used as the root node of the sub tree, 29. call RLID3 algorithm, 30. updateRLID3Tree(the node that corresponds to the first j value, childrenTrainData[j]), subtree traversal 31. } 32. }else{//the attribute of curNode is not the same as A 33. the node that corresponds to the first j value is used as the root node of the sub tree, 34. call RLID3 algorithm, 35. updateRLID3Tree(the node that corresponds to the first j value, childrenTrainData[j]), subtree traversal 36. } 37. } 38. } 39. } |
|