weka.classifiers.trees
Class RandomTree

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--weka.classifiers.trees.RandomTree
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, Randomizable, java.io.Serializable, WeightedInstancesHandler

public class RandomTree
extends Classifier
implements OptionHandler, WeightedInstancesHandler, Randomizable

Class for constructing a tree that considers K random features at each node. Performs no pruning.

Version:
$Revision: 1.7 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Richard Kirkby (rkirkby@cs.waikato.ac.nz)
See Also:
Serialized Form

Constructor Summary
RandomTree()
           
 
Method Summary
 void buildClassifier(Instances data)
          Builds classifier.
 java.lang.String debugTipText()
          Returns the tip text for this property
 double[] distributionForInstance(Instance instance)
          Computes class distribution of an instance using the decision tree.
 boolean getDebug()
          Get the value of Debug.
 int getKValue()
          Get the value of K.
 double getMinNum()
          Get the value of MinNum.
 java.lang.String[] getOptions()
          Gets options from this classifier.
 int getSeed()
          Gets the seed for the random number generations
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.lang.String KValueTipText()
          Returns the tip text for this property
 java.util.Enumeration listOptions()
          Lists the command-line options for this classifier.
static void main(java.lang.String[] argv)
          Main method for this class.
 java.lang.String minNumTipText()
          Returns the tip text for this property
 int numNodes()
          Computes size of the tree.
 java.lang.String seedTipText()
          Returns the tip text for this property
 void setDebug(boolean newDebug)
          Set the value of Debug.
 void setKValue(int k)
          Set the value of K.
 void setMinNum(double newMinNum)
          Set the value of MinNum.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSeed(int seed)
          Set the seed for random number generation.
 java.lang.String toGraph()
          Outputs the decision tree as a graph
 int toGraph(java.lang.StringBuffer text, int num)
          Outputs one node for graph.
 java.lang.String toString()
          Outputs the decision tree.
 
Methods inherited from class weka.classifiers.Classifier
classifyInstance, forName, makeCopies
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomTree

public RandomTree()
Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

minNumTipText

public java.lang.String minNumTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getMinNum

public double getMinNum()
Get the value of MinNum.

Returns:
Value of MinNum.

setMinNum

public void setMinNum(double newMinNum)
Set the value of MinNum.

Parameters:
newMinNum - Value to assign to MinNum.

KValueTipText

public java.lang.String KValueTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getKValue

public int getKValue()
Get the value of K.

Returns:
Value of K.

setKValue

public void setKValue(int k)
Set the value of K.

Parameters:
k - Value to assign to K.

debugTipText

public java.lang.String debugTipText()
Returns the tip text for this property

Overrides:
debugTipText in class Classifier
Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getDebug

public boolean getDebug()
Get the value of Debug.

Overrides:
getDebug in class Classifier
Returns:
Value of Debug.

setDebug

public void setDebug(boolean newDebug)
Set the value of Debug.

Overrides:
setDebug in class Classifier
Parameters:
newDebug - Value to assign to Debug.

seedTipText

public java.lang.String seedTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setSeed

public void setSeed(int seed)
Set the seed for random number generation.

Specified by:
setSeed in interface Randomizable
Parameters:
seed - the seed

getSeed

public int getSeed()
Gets the seed for the random number generations

Specified by:
getSeed in interface Randomizable
Returns:
the seed for the random number generation

listOptions

public java.util.Enumeration listOptions()
Lists the command-line options for this classifier.

Specified by:
listOptions in interface OptionHandler
Overrides:
listOptions in class Classifier
Returns:
an enumeration of all available options.

getOptions

public java.lang.String[] getOptions()
Gets options from this classifier.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class Classifier
Returns:
the list of current option settings as an array of strings

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class Classifier
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Builds classifier.

Specified by:
buildClassifier in class Classifier
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully

distributionForInstance

public double[] distributionForInstance(Instance instance)
                                 throws java.lang.Exception
Computes class distribution of an instance using the decision tree.

Overrides:
distributionForInstance in class Classifier
Parameters:
instance - the instance to be classified
Returns:
an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
Throws:
java.lang.Exception - if distribution could not be computed successfully

toGraph

public java.lang.String toGraph()
Outputs the decision tree as a graph


toGraph

public int toGraph(java.lang.StringBuffer text,
                   int num)
            throws java.lang.Exception
Outputs one node for graph.

java.lang.Exception

toString

public java.lang.String toString()
Outputs the decision tree.

Overrides:
toString in class java.lang.Object

numNodes

public int numNodes()
Computes size of the tree.


main

public static void main(java.lang.String[] argv)
Main method for this class.



Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London