示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }