Ejemplo n.º 1
0
        public static DecisionTree Build(List <PointXD> data)
        {
            DecisionTree tree = new DecisionTree();

            data.ForEach(point => tree.HandlePoint(point));
            tree.Simplify();
            return(tree);
        }
Ejemplo n.º 2
0
        private DecisionTree HandlePoint(PointXD point, int paramCount = 0)
        {
            if (paramCount == point.Count)
            {
                Answer = point.Class;
                return(this);
            }

            Question = paramCount;
            object       param = point.Attributes[paramCount];
            DecisionTree tree  = Branches.ContainsKey(param) ? Branches[param] : new DecisionTree();

            Branches[param] = tree.HandlePoint(point, ++paramCount);

            return(this);
        }