public Map<String, OrdinalAttribute> classify(State state) throws ClassifyingFailureException
    {
        // Start at the root of the decision tree.
        DecisionTree currentNode = dt;

        // Loop down the decision tree until a leaf node is found.
        while (true) // !currentNode.isLeaf())
        {
            DecisionTreeElement element = currentNode.getElement();

            // Check that the current element really is a decision.
            if (element instanceof Decision)
            {
                Decision decision = (Decision) element;

                // Apply the decision at the current node to the state to be classified to get a new tree.
                currentNode = decision.decide(state); // , currentNode);
            }
            else if (element instanceof Assignment)
            {
                // Cast the element to an Assignment as this is the only type of leaf that is possible.
                Assignment assignment = (Assignment) element;

                // Return the assignment in a map.
                Map<String, OrdinalAttribute> assignmentMap = new HashMap<String, OrdinalAttribute>();

                assignmentMap.put(assignment.getPropertyName(), assignment.getAttribute());

                return assignmentMap;
            }

            // It is possible that a node may be of type Pending if an incomplete tree has been used to
            // run this classification on.
            else
            {
                // Throw a classification exception due to an incomplete decision tree.
                throw new ClassifyingFailureException("A node which is not a decision was encountered.", null);
            }
            // What happens if the decision could not operate on the state, either because of a missing property or
            // because its property was not of the type that the decision was expecting? Can either throw an exception,
            // return an empty assignment, or implement an algorithm for coping with missing properties.
        }
    }
public Map<String, OrdinalAttribute> classify(State state) throws ClassifyingFailureException
    {
        
        DecisionTree currentNode = dt;

        
        while (true) 
        {
            DecisionTreeElement element = currentNode.getElement();

            
            if (element instanceof Decision)
            {
                Decision decision = (Decision) element;

                
                currentNode = decision.decide(state); 
            }
            else if (element instanceof Assignment)
            {
                
                Assignment assignment = (Assignment) element;

                
                Map<String, OrdinalAttribute> assignmentMap = new HashMap<String, OrdinalAttribute>();

                assignmentMap.put(assignment.getPropertyName(), assignment.getAttribute());

                return assignmentMap;
            }

            
            
            else
            {
                
                throw new ClassifyingFailureException("A node which is not a decision was encountered.", null);
            }
            
            
            
        }
    }
public Map < String , OrdinalAttribute > classify ( State state ) throws ClassifyingFailureException { // Start at the root of the decision tree. DecisionTree currentNode = dt ; // Loop down the decision tree until a leaf node is found. while ( true ) // !currentNode.isLeaf()) { DecisionTreeElement element = currentNode . getElement ( ) ; // Check that the current element really is a decision. if ( element instanceof Decision ) { Decision decision = ( Decision ) element ; // Apply the decision at the current node to the state to be classified to get a new tree. currentNode = decision . decide ( state ) ; // , currentNode); } else if ( element instanceof Assignment ) { // Cast the element to an Assignment as this is the only type of leaf that is possible. Assignment assignment = ( Assignment ) element ; // Return the assignment in a map. Map < String , OrdinalAttribute > assignmentMap = new HashMap < String , OrdinalAttribute > ( ) ; assignmentMap . put ( assignment . getPropertyName ( ) , assignment . getAttribute ( ) ) ; return assignmentMap ; } // It is possible that a node may be of type Pending if an incomplete tree has been used to // run this classification on. else { // Throw a classification exception due to an incomplete decision tree. throw new ClassifyingFailureException ( "A node which is not a decision was encountered." , null ) ; } // What happens if the decision could not operate on the state, either because of a missing property or // because its property was not of the type that the decision was expecting? Can either throw an exception, // return an empty assignment, or implement an algorithm for coping with missing properties. } }
Classifies a state using the decision tree.

@param  state The input data point to classify.

@return A classification of the data point as an mapping from the output property that the decision tree was
trained on to this classifiers belief abouts its value.

@throws ClassifyingFailureException If the decision tree is not completed and this classifier encounters a
pending node in the tree that is still to be built.
Classifies a state using the decision tree .