示例#1
0
 private DecisionTreeNode train(DataTable dataTable, DecisionTreeNode root)
 {
     if (dataTable.IsHomogeneous)
     {
         root.ClassLabel = dataTable.FirstClassLabel;
         return(root);
     }
     else
     {
         var splitParams = dataTable.DecideSplitParams();
         root.SplitDetails = splitParams;
         var tableSplit = dataTable.Split(splitParams.DimensionIndex, splitParams.Value);
         if (!tableSplit.SplitTable.IsEmpty)
         {
             var firstChildNode = train(tableSplit.SplitTable, new DecisionTreeNode());
             root.FirstChildDetails = new Tuple <string, DecisionTreeNode>(splitParams.Value, firstChildNode);
         }
         if (!tableSplit.UnSplitTable.IsEmpty)
         {
             root.SecondChild = train(tableSplit.UnSplitTable, new DecisionTreeNode());
         }
         return(root);
     }
 }
示例#2
0
 public void SetFirstChildDetails(string value, DecisionTreeNode firstChild)
 {
     this.firstChildDetails = new Tuple <string, DecisionTreeNode>(value, firstChild);
 }