Exemple #1
0
        /// <summary>
        /// Given a Case by which to test with a ID3_Node representing a decision tree, find the tree's label variant number for the Case and return it.
        /// </summary>
        /// <returns></returns>
        public static int TestWithTree(Case test, ID3_Node Tree)
        {
            if (ReferenceEquals(Tree.getChildren(), null))
            {
                return(Tree.Value);
            }

            /*
             * if(Tree.getChildren()[test.AttributeVals[Tree.AttributeID]] == null) //if the child is null pick another value that is valid. (example not present in training data)
             * {
             *  if(Tree.getChildren().Length == test.AttributeVals[Tree.AttributeID])
             * }*/

            // we have to assume that the attribute values are integers and that the attributes are not purely numeric
            return(TestWithTree(test, Tree.getChildren()[(int)test.AttributeVals[Tree.AttributeID]]));
        }