learn
Class DecisionTree

java.lang.Object
  |
  +--learn.DecisionTree

public class DecisionTree
extends java.lang.Object
implements java.io.Serializable

The DecisionTree class implements a decision tree.

See Also:
Serialized Form

Field Summary
protected  Variable classVar
           
protected  DataSet ds
           
protected  java.util.Vector examples
           
protected  java.lang.String name
           
protected  java.lang.String[] record
           
protected static javax.swing.JTextArea textArea1
           
protected  java.util.Hashtable variableList
           
 
Constructor Summary
DecisionTree(java.lang.String Name)
          Creates an instance of a decision tree with the given name.
 
Method Summary
static void appendText(java.lang.String text)
          Appends text to the text area.
 Node buildDecisionTree(java.util.Vector examples, java.util.Hashtable variables, Node defaultValue)
          Constructs a decision tree with the given a vector of example data records, splitting on variables and values with the most information content.
(package private)  Variable chooseVariable(java.util.Hashtable variables, java.util.Vector examples)
          Chooses the variable with the greatest gain.
(package private)  double computeInfo(int p, int n)
          Computes the information content, given the number of positive and negative examples.
(package private)  double computeRemainder(Variable variable, java.util.Vector examples)
          Computes the remainder value for the given variable and vector.
 int[] getCounts(java.util.Vector examples)
          Returns an integer array containing the number of occurrences of each discrete value in the given vector.
 boolean identical(java.util.Vector examples, Variable variable)
          Determines whether each record in the examples vector matches the given variable value.
 java.lang.String majority(java.util.Vector examples)
          Returns the value which occurs most often in the given vector.
(package private)  java.util.Vector subset(java.util.Vector examples, Variable variable, java.lang.String value)
          Returns a subset of a vector where the variable name equals the given value.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

ds

protected DataSet ds

classVar

protected Variable classVar

variableList

protected java.util.Hashtable variableList

examples

protected java.util.Vector examples

textArea1

protected static javax.swing.JTextArea textArea1

record

protected java.lang.String[] record
Constructor Detail

DecisionTree

public DecisionTree(java.lang.String Name)
Creates an instance of a decision tree with the given name.
Parameters:
name - the String object that contains the name of this decision tree
Name - the String object
Method Detail

appendText

public static void appendText(java.lang.String text)
Appends text to the text area.
Parameters:
text - the String object that contains the text to be displayed

identical

public boolean identical(java.util.Vector examples,
                         Variable variable)
Determines whether each record in the examples vector matches the given variable value.
Parameters:
examples - the Vector object that contains the records
variable - the Variable object that contains the value to be matched
Returns:
the boolean that contains true if the records match and false if they do not

majority

public java.lang.String majority(java.util.Vector examples)
Returns the value which occurs most often in the given vector.
Parameters:
examples - the Vector object which is examined
Returns:
the String object that occurs most often

getCounts

public int[] getCounts(java.util.Vector examples)
Returns an integer array containing the number of occurrences of each discrete value in the given vector.
Parameters:
examples - the Vector object that contains the discrete values
Returns:
the int[] that contains the number of occurrences of each discrete value

computeInfo

double computeInfo(int p,
                   int n)
Computes the information content, given the number of positive and negative examples.
Parameters:
p - the number of positve values
n - the number of negative values
Returns:
the double value that represents the information content

computeRemainder

double computeRemainder(Variable variable,
                        java.util.Vector examples)
Computes the remainder value for the given variable and vector.
Parameters:
variable - the Variable object for which the remainder is computed
examples - the Vector object that contains the records
Returns:
the double value that represents the computed remainder

subset

java.util.Vector subset(java.util.Vector examples,
                        Variable variable,
                        java.lang.String value)
Returns a subset of a vector where the variable name equals the given value.
Parameters:
examples - the Vector object that contains the records
variable - the Variable object
value - the String value to be matched
Returns:
the Vector object that contains the matching records

chooseVariable

Variable chooseVariable(java.util.Hashtable variables,
                        java.util.Vector examples)
Chooses the variable with the greatest gain.
Parameters:
variables - the Hashtable object that contains the variables
examples - the Vector object that contains the records
Returns:
the Variable object with the greatest gain

buildDecisionTree

public Node buildDecisionTree(java.util.Vector examples,
                              java.util.Hashtable variables,
                              Node defaultValue)
Constructs a decision tree with the given a vector of example data records, splitting on variables and values with the most information content.
Parameters:
examples - the Vector object that contains the example records
variables - the Hashtable object that contains the variables
defaultValue - the Node object that contains the default value if the tree cannot be built from the examples
Returns:
the Node object that is the root of the tree