예제 #1
0
 public void RecurseRead (string[] fileLines, ref int i)
 {
     string line = fileLines[i];
     i++;
     string[] lineParts = line.Split(',');
     if (lineParts.Length == 1)
     {
         Classification = float.Parse(lineParts[0]);
     }
     else
     {
         BranchComponent = int.Parse(lineParts[0]);
         BranchValue = float.Parse(lineParts[1]);
         LeftBranch = new DecisionTree();
         LeftBranch.RecurseRead(fileLines, ref i);
         RightBranch = new DecisionTree();
         RightBranch.RecurseRead(fileLines, ref i);
     }
 }
예제 #2
0
 public void Unload ()
 {
     Root = null;
 }
예제 #3
0
 public void Load ()
 {
     Root = new DecisionTree(Filename);
 }
예제 #4
0
 public BigDecisionTree(Dataset Dataset, int MaxTreeDepth, int CurrentDepth = 0)
 {
     Root = new DecisionTree(Dataset, MaxTreeDepth);
     Filename = "./trees/" + Now().ToString() + "." + RNG.Next(0, 65535);
     Root.Write(Filename);
 }
예제 #5
0
        private void DoBranch(Dataset Dataset, int MaxTreeDepth, int CurrentDepth)
        {
            Dataset leftDataset;
            Dataset rightDataset;
            int timeout = 0;
            do
            {
                timeout++;
                if (timeout > 1000)
                {
                    DetermineClassification(Dataset);
                }
                BranchComponent = RNG.Next(Dataset.Inputs[0].Count);
                float componentLow;
                float componentHigh;
                float componentRange;
                Dataset.GetInputComponentRange(BranchComponent, out componentLow, out componentHigh, out componentRange);
                BranchValue = (float)((RNG.NextDouble() * componentRange) + componentLow);
                leftDataset = new Dataset();
                rightDataset = new Dataset();
                Split(BranchComponent, BranchValue, Dataset, out leftDataset, out rightDataset);
            } while (leftDataset.Inputs.Count == 0 || rightDataset.Inputs.Count == 0);

            LeftBranch = new DecisionTree(leftDataset, MaxTreeDepth, CurrentDepth + 1);
            RightBranch = new DecisionTree(rightDataset, MaxTreeDepth, CurrentDepth + 1);
        }