예제 #1
0
 public void RecurseRead(string[] fileLines, ref int i)
 {
     string line = fileLines[i];
     i++;
     string[] lineParts = line.Split(',');
     if (lineParts[0] == "0")
     {
         Regression = new List<float>();
         for (int l = 1; l < lineParts.Length; l++)
         {
             Regression.Add(float.Parse(lineParts[l]));
         }
     }
     else
     {
         BranchComponent = int.Parse(lineParts[0]);
         BranchValue = float.Parse(lineParts[1]);
         LeftBranch = new RegressionTree();
         LeftBranch.RecurseRead(fileLines, ref i);
         RightBranch = new RegressionTree();
         RightBranch.RecurseRead(fileLines, ref i);
     }
 }
예제 #2
0
 public void Unload()
 {
     Root = null;
 }
예제 #3
0
 public void Load()
 {
     Root = new RegressionTree(Filename);
 }
예제 #4
0
 public BigRegressionTree(Dataset Dataset, int MaxTreeDepth, int CurrentDepth = 0)
 {
     Root = new RegressionTree(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)
                {
                    DetermineRegression(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 RegressionTree(leftDataset, MaxTreeDepth, CurrentDepth + 1);
            RightBranch = new RegressionTree(rightDataset, MaxTreeDepth, CurrentDepth + 1);
        }