private void Learn()
        {
            //build the tree using CART algorithm
            Queue <DecisionTreeNode> qe = new Queue <DecisionTreeNode>();

            qe.Enqueue(Head);
            int counter = 0;

            while (GeneralMethods.FindErrorSum(this) > 0)
            {
                DecisionTreeNode tempNode = new DecisionTreeNode();
                tempNode = qe.Dequeue();
                if (GeneralMethods.CountError(tempNode.Elements) != 0)
                {
                    tempNode.Rule = new Rule(tempNode.Elements);
                    AddChildren(tempNode);
                    qe.Enqueue(tempNode.LeftChild);
                    qe.Enqueue(tempNode.RightChild);
                    counter++;
                }
            }
            TreeError = GeneralMethods.FindErrorSum(this);
        }
Exemple #2
0
        public static double FindErrorInNode(Data[] elements, int allElements)
        {
            double error = GeneralMethods.CountError(elements) * elements.Length;

            return(error / allElements);
        }