Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 public void Unload ()
 {
     Root = null;
 }
Ejemplo n.º 3
0
 public void Load ()
 {
     Root = new DecisionTree(Filename);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }