weka.clusterers
Class Cobweb

java.lang.Object
  extended byweka.clusterers.Clusterer
      extended byweka.clusterers.Cobweb
All Implemented Interfaces:
java.lang.Cloneable, Drawable, OptionHandler, java.io.Serializable

public class Cobweb
extends Clusterer
implements OptionHandler, Drawable

Class implementing the Cobweb and Classit clustering algorithms.

Note: the application of node operators (merging, splitting etc.) in terms of ordering and priority differs (and is somewhat ambiguous) between the original Cobweb and Classit papers. This algorithm always compares the best host, adding a new leaf, merging the two best hosts, and splitting the best host when considering where to place a new instance.

Valid options are:

-A
Acuity.

-C
Cutoff.

Version:
$Revision: 1.16 $
Author:
Mark Hall
See Also:
Clusterer, OptionHandler, Drawable, Serialized Form

Nested Class Summary
private  class Cobweb.CNode
          Inner class handling node operations for Cobweb.
 
Field Summary
protected  double m_acuity
          Acuity (minimum standard deviation).
protected  Cobweb.CNode m_cobwebTree
          Holds the root of the Cobweb tree.
protected  double m_cutoff
          Cutoff (minimum category utility).
protected static double m_normal
          Normal constant.
protected  int m_numberMerges
           
protected  int m_numberOfClusters
          Number of clusters (nodes in the tree).
protected  int m_numberSplits
           
protected  boolean m_saveInstances
          Output instances in graph representation of Cobweb tree (Allows instances at nodes in the tree to be visualized in the Explorer).
 
Fields inherited from interface weka.core.Drawable
BayesNet, NOT_DRAWABLE, TREE
 
Constructor Summary
Cobweb()
           
 
Method Summary
 java.lang.String acuityTipText()
          Returns the tip text for this property
 void addInstance(Instance newInstance)
          Adds an instance to the Cobweb tree.
 void buildClusterer(Instances data)
          Builds the clusterer.
 int clusterInstance(Instance instance)
          Classifies a given instance.
 java.lang.String cutoffTipText()
          Returns the tip text for this property
 double getAcuity()
          get the acuity value
 double getCutoff()
          get the cutoff
 java.lang.String[] getOptions()
          Gets the current settings of Cobweb.
 boolean getSaveInstanceData()
          Get the value of saveInstances.
 java.lang.String graph()
          Generates the graph string of the Cobweb tree
 int graphType()
          Returns the type of graphs this class represents
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] argv)
           
 int numberOfClusters()
          Returns the number of clusters.
 java.lang.String saveInstanceDataTipText()
          Returns the tip text for this property
 void setAcuity(double a)
          set the acuity.
 void setCutoff(double c)
          set the cutoff
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSaveInstanceData(boolean newsaveInstances)
          Set the value of saveInstances.
 java.lang.String toString()
          Returns a description of the clusterer as a string.
 
Methods inherited from class weka.clusterers.Clusterer
distributionForInstance, forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_normal

protected static final double m_normal
Normal constant.


m_acuity

protected double m_acuity
Acuity (minimum standard deviation).


m_cutoff

protected double m_cutoff
Cutoff (minimum category utility).


m_cobwebTree

protected Cobweb.CNode m_cobwebTree
Holds the root of the Cobweb tree.


m_numberOfClusters

protected int m_numberOfClusters
Number of clusters (nodes in the tree).


m_numberSplits

protected int m_numberSplits

m_numberMerges

protected int m_numberMerges

m_saveInstances

protected boolean m_saveInstances
Output instances in graph representation of Cobweb tree (Allows instances at nodes in the tree to be visualized in the Explorer).

Constructor Detail

Cobweb

public Cobweb()
Method Detail

buildClusterer

public void buildClusterer(Instances data)
                    throws java.lang.Exception
Builds the clusterer.

Specified by:
buildClusterer in class Clusterer
Parameters:
data - the training instances.
Throws:
java.lang.Exception - if something goes wrong.

clusterInstance

public int clusterInstance(Instance instance)
                    throws java.lang.Exception
Classifies a given instance.

Overrides:
clusterInstance in class Clusterer
Parameters:
instance - the instance to be assigned to a cluster
Returns:
the number of the assigned cluster as an interger if the class is enumerated, otherwise the predicted value
Throws:
java.lang.Exception - if instance could not be classified successfully

numberOfClusters

public int numberOfClusters()
                     throws java.lang.Exception
Returns the number of clusters.

Specified by:
numberOfClusters in class Clusterer
Returns:
the number of clusters generated for a training dataset.
Throws:
java.lang.Exception - if something goes wrong.

addInstance

public void addInstance(Instance newInstance)
                 throws java.lang.Exception
Adds an instance to the Cobweb tree.

Parameters:
newInstance - the instance to be added
Throws:
java.lang.Exception - if something goes wrong

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options.

setOptions

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

-A
Acuity.

-C
Cutoff.

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

acuityTipText

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

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

setAcuity

public void setAcuity(double a)
set the acuity.

Parameters:
a - the acuity value

getAcuity

public double getAcuity()
get the acuity value

Returns:
the acuity

cutoffTipText

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

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

setCutoff

public void setCutoff(double c)
set the cutoff

Parameters:
c - the cutof

getCutoff

public double getCutoff()
get the cutoff

Returns:
the cutoff

saveInstanceDataTipText

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

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

getSaveInstanceData

public boolean getSaveInstanceData()
Get the value of saveInstances.

Returns:
Value of saveInstances.

setSaveInstanceData

public void setSaveInstanceData(boolean newsaveInstances)
Set the value of saveInstances.

Parameters:
newsaveInstances - Value to assign to saveInstances.

getOptions

public java.lang.String[] getOptions()
Gets the current settings of Cobweb.

Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions()

toString

public java.lang.String toString()
Returns a description of the clusterer as a string.

Returns:
a string describing the clusterer.

graphType

public int graphType()
Returns the type of graphs this class represents

Specified by:
graphType in interface Drawable
Returns:
Drawable.TREE

graph

public java.lang.String graph()
                       throws java.lang.Exception
Generates the graph string of the Cobweb tree

Specified by:
graph in interface Drawable
Returns:
a String value
Throws:
java.lang.Exception - if an error occurs

main

public static void main(java.lang.String[] argv)