private double ResolveRecursion(IItemNumerical item, Node.Node node) { double res = 0; if (node == null) { throw new Exception(); } if (node.IsTerminal) { return(node.Average); } if (!item.HasValue(node.FeatureName)) { throw new Exception(); } var v = item.GetValue(node.FeatureName); if (v < node.FeatureValue) { res = ResolveRecursion(item, node.Less); } else { res = ResolveRecursion(item, node.Greater); } return(res); }
public Tree ToTree() { Node.Node io = ToTreeRecursion(Root); Tree t = new Tree(); t.FeatureNames = FeatureNames.ToList(); t.ResolutionFeatureName = ResolutionFeatureName; t.MaxItemCountInCategory = MaxItemCountInCategory; t.Root = io; return(t); }
private static Node.Node ToTreeRecursion(NodeGenerative node) { Node.Node res = new Node.Node(node); if (node.Left != null) { ToTreeRecursion(node.Left); } if (node.Right != null) { ToTreeRecursion(node.Right); } return(res); }