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); } }
public void Unload() { Root = null; }
public void Load() { Root = new RegressionTree(Filename); }
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); }
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); }