Class ClassifierTree

    • Constructor Detail

      • ClassifierTree

        public ClassifierTree​(ModelSelection toSelectLocModel)
        Constructor.
    • Method Detail

      • isLeaf

        public boolean isLeaf()
      • getTrainingData

        public Instances getTrainingData()
      • buildClassifier

        public void buildClassifier​(Instances data)
                             throws Exception
        Method for building a classifier tree.
        Parameters:
        data - the data to build the tree from
        Throws:
        Exception - if something goes wrong
      • buildTree

        public void buildTree​(Instances data,
                              boolean keepData)
                       throws Exception
        Builds the tree structure.
        Parameters:
        data - the data for which the tree structure is to be generated.
        keepData - is training data to be kept?
        Throws:
        Exception - if something goes wrong
      • buildTree

        public void buildTree​(Instances train,
                              Instances test,
                              boolean keepData)
                       throws Exception
        Builds the tree structure with hold out set
        Parameters:
        train - the data for which the tree structure is to be generated.
        test - the test data for potential pruning
        keepData - is training Data to be kept?
        Throws:
        Exception - if something goes wrong
      • classifyInstance

        public double classifyInstance​(Instance instance)
                                throws Exception
        Classifies an instance.
        Parameters:
        instance - the instance to classify
        Returns:
        the classification
        Throws:
        Exception - if something goes wrong
      • cleanup

        public void cleanup​(Instances justHeaderInfo)
        Cleanup in order to save memory.
        Parameters:
        justHeaderInfo -
      • distributionForInstance

        public double[] distributionForInstance​(Instance instance,
                                                boolean useLaplace)
                                         throws Exception
        Returns class probabilities for a weighted instance.
        Parameters:
        instance - the instance to get the distribution for
        useLaplace - whether to use laplace or not
        Returns:
        the distribution
        Throws:
        Exception - if something goes wrong
      • assignIDs

        public int assignIDs​(int lastID)
        Assigns a uniqe id to every node in the tree.
        Parameters:
        lastID - the last ID that was assign
        Returns:
        the new current ID
      • graphType

        public int graphType()
        Returns the type of graph this classifier represents.
        Specified by:
        graphType in interface Drawable
        Returns:
        Drawable.TREE
      • graph

        public String graph()
                     throws Exception
        Returns graph describing the tree.
        Specified by:
        graph in interface Drawable
        Returns:
        the tree as graph
        Throws:
        Exception - if something goes wrong
      • prefix

        public String prefix()
                      throws Exception
        Returns tree in prefix order.
        Returns:
        the prefix order
        Throws:
        Exception - if something goes wrong
      • toSource

        public StringBuffer[] toSource​(String className)
                                throws Exception
        Returns source code for the tree as an if-then statement. The class is assigned to variable "p", and assumes the tested instance is named "i". The results are returned as two stringbuffers: a section of code for assignment of the class, and a section of code containing support code (eg: other support methods).
        Parameters:
        className - the classname that this static classifier has
        Returns:
        an array containing two stringbuffers, the first string containing assignment code, and the second containing source for support code.
        Throws:
        Exception - if something goes wrong
      • numLeaves

        public int numLeaves()
        Returns number of leaves in tree structure.
        Returns:
        the number of leaves
      • numNodes

        public int numNodes()
        Returns number of nodes in tree structure.
        Returns:
        the number of nodes
      • toString

        public String toString()
        Prints tree structure.
        Overrides:
        toString in class Object
        Returns:
        the tree structure
      • getMembershipValues

        public double[] getMembershipValues​(Instance instance)
                                     throws Exception
        Computes a list that indicates node membership
        Throws:
        Exception