Esempio n. 1
0
        public DNode(DataSet classify, ref bool[] marked, string path)
        {
            //Console.WriteLine(markedString(marked));
            classification = null; //only gets set on leaf node
            attr_assigned = false; //unassigned
            this.path = path;

            //if the tree is perfectly classified (entropy == 0)
            // or if we're out of attributes, return the most occuring one
            if(classify.entropy == 0 || allMarked(ref marked))
            { classification = classify.getMostOccuringClassification();}
            else
            {
                attribute = classify.bestGain(marked);
                attr_assigned = true;
                children = new DNode[classify.getAttributes(attribute).Length];
                //Console.WriteLine("Attrib: " + attribute + " Children: " + classify.getAttributes(attribute).Length);
                for(uint x=0; x < children.Length; x++)
                {
                    marked[attribute] = true;
                    string tmp = classify.getAttributes(attribute)[x];
                    children[x] = new DNode(classify.partitionData(attribute,tmp),ref marked,tmp);
                }
            }
        }