Ejemplo n.º 1
0
        public SimpleDecisionTreeBuilder(ItemSet learningItemSet, AttributeSet testAttributeSet, SymbolicAttribute goalAttribute)
        {
            System.Console.WriteLine("Inside the tree builder!!!!!!!!!!");
            if (learningItemSet == null || learningItemSet.NumOfItems() == 0)
            {
                throw new ArgumentNullException();
            }

            this._learningSet      = learningItemSet;
            this._testAttributeSet = testAttributeSet;
            this._goalAttribute    = goalAttribute;

            LearningDecisionTree tree =
                new LearningDecisionTree(learningItemSet.AttrSet, goalAttribute, learningItemSet);

            this._tree = tree;
        }
        /// <summary>
        /// Construct a Decision tree object with only test nodes.
        /// This function is useful after a LearningDecision Tree is trained. The
        /// Test decision tree object is light-weighted and easy for serialization.
        /// </summary>
        /// <param name="ldt">A traininged learning decision tree</param>
        /// <returns></returns>
        private TestDecisionTree GetTestDecisionTree(LearningDecisionTree ldt)
        {
            try
            {
                List <Node> nodeList = this.ConvertToTestNode(ldt.BFIterator()).ToList();

                this._nodes = nodeList.ToArray();

                this.AttributeSet  = ldt.AttributeSet;
                this.GoalAttribute = ldt.GoalAttribute;

                return(GetTestDecisionTree(nodeList));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public TestDecisionTree(LearningDecisionTree ldt)
 {
     GetTestDecisionTree(ldt);
 }