Package weka.clusterers

# Class HierarchicalClusterer

java.lang.Object
weka.clusterers.AbstractClusterer
weka.clusterers.HierarchicalClusterer

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Clusterer`, `CapabilitiesHandler`, `CapabilitiesIgnorer`, `CommandlineRunnable`, `Drawable`, `OptionHandler`, `RevisionHandler`

public class HierarchicalClusterer extends AbstractClusterer implements OptionHandler, Drawable
Hierarchical clustering class. Implements a number of classic hierarchical clustering methods. Valid options are:

     -N
      number of clusters

     -L
      Link type (Single, Complete, Average, Mean, Centroid, Ward, Adjusted complete, Neighbor Joining)
      [SINGLE|COMPLETE|AVERAGE|MEAN|CENTROID|WARD|ADJCOMPLETE|NEIGHBOR_JOINING]

     -A
     Distance function to use. (default: weka.core.EuclideanDistance)

     -P
     Print hierarchy in Newick format, which can be used for display in other programs.

     -D
     If set, classifier is run in debug mode and may output additional info to the console.

     -B
     \If set, distance is interpreted as branch length, otherwise it is node height.

Version:
  $Revision: 15520 $
Author:
  Remco Bouckaert (rrb@xm.co.nz, remco@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz)
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Tag[]`
  `TAGS_LINK_TYPE`

  ### Fields inherited from interface weka.core.Drawable

  `BayesNet, Newick, NOT_DRAWABLE, TREE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HierarchicalClusterer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `buildClusterer(Instances data)`
  Generates a clusterer.
  `int`
  `clusterInstance(Instance instance)`
  Classifies a given instance.
  `String`
  `distanceFunctionTipText()`
  `String`
  `distanceIsBranchLengthTipText()`
  `double[]`
  `distributionForInstance(Instance instance)`
  Predicts the cluster memberships for a given instance.
  `Capabilities`
  `getCapabilities()`
  Returns the Capabilities of this clusterer.
  `DistanceFunction`
  `getDistanceFunction()`
  `boolean`
  `getDistanceIsBranchLength()`
  `SelectedTag`
  `getLinkType()`
  `int`
  `getNumClusters()`
  `String[]`
  `getOptions()`
  Gets the current settings of the clusterer.
  `boolean`
  `getPrintNewick()`
  `String`
  `getRevision()`
  Returns the revision string.
  `String`
  `globalInfo()`
  This will return a string describing the clusterer.
  `String`
  `graph()`
  Returns a string that describes a graph representing the object.
  `int`
  `graphType()`
  Returns the type of graph representing the object.
  `String`
  `linkTypeTipText()`
  `Enumeration<Option>`
  `listOptions()`
  Returns an enumeration describing the available options.
  `static void`
  `main(String[] argv)`
  `int`
  `numberOfClusters()`
  Returns the number of clusters.
  `String`
  `numClustersTipText()`
  `String`
  `printNewickTipText()`
  `void`
  `setDistanceFunction(DistanceFunction distanceFunction)`
  `void`
  `setDistanceIsBranchLength(boolean bDistanceIsHeight)`
  `void`
  `setLinkType(SelectedTag newLinkType)`
  `void`
  `setNumClusters(int nClusters)`
  `void`
  `setOptions(String[] options)`
  Parses a given list of options.
  `void`
  `setPrintNewick(boolean bPrintNewick)`
  `String`
  `toString()`

  ### Methods inherited from class weka.clusterers.AbstractClusterer

  `debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, makeCopies, makeCopy, postExecution, preExecution, run, runClusterer, setDebug, setDoNotCheckCapabilities`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### TAGS_LINK_TYPE

    public static final Tag[] TAGS_LINK_TYPE

- ## Constructor Details

  - ### HierarchicalClusterer

    public HierarchicalClusterer()

- ## Method Details

  - ### setNumClusters

    public void setNumClusters(int nClusters)

  - ### getNumClusters

    public int getNumClusters()

  - ### getDistanceFunction

    public DistanceFunction getDistanceFunction()

  - ### setDistanceFunction

    public void setDistanceFunction(DistanceFunction distanceFunction)

  - ### getPrintNewick

    public boolean getPrintNewick()

  - ### setPrintNewick

    public void setPrintNewick(boolean bPrintNewick)

  - ### setLinkType

    public void setLinkType(SelectedTag newLinkType)

  - ### getLinkType

    public SelectedTag getLinkType()

  - ### buildClusterer

    public void buildClusterer(Instances data) throws Exception
    Description copied from class: `AbstractClusterer`
    Generates a clusterer. Has to initialize all fields of the clusterer that are not being set via options.
    Specified by:
      `buildClusterer` in interface `Clusterer`
    Specified by:
      `buildClusterer` in class `AbstractClusterer`
    Parameters:
      `data` - set of instances serving as training data
    Throws:
      `Exception` - if the clusterer has not been generated successfully

  - ### clusterInstance

    public int clusterInstance(Instance instance) throws Exception
    Description copied from class: `AbstractClusterer`
    Classifies a given instance. Either this or distributionForInstance() needs to be implemented by subclasses.
    Specified by:
      `clusterInstance` in interface `Clusterer`
    Overrides:
      `clusterInstance` in class `AbstractClusterer`
    Parameters:
      `instance` - the instance to be assigned to a cluster
    Returns:
      the number of the assigned cluster as an integer
    Throws:
      `Exception` - if instance could not be clustered successfully

  - ### distributionForInstance

    public double[] distributionForInstance(Instance instance) throws Exception
    Description copied from class: `AbstractClusterer`
    Predicts the cluster memberships for a given instance. Either this or clusterInstance() needs to be implemented by subclasses.
    Specified by:
      `distributionForInstance` in interface `Clusterer`
    Overrides:
      `distributionForInstance` in class `AbstractClusterer`
    Parameters:
      `instance` - the instance to be assigned a cluster.
    Returns:
      an array containing the estimated membership probabilities of the test instance in each cluster (this should sum to at most 1)
    Throws:
      `Exception` - if distribution could not be computed successfully

  - ### getCapabilities

    public Capabilities getCapabilities()
    Description copied from class: `AbstractClusterer`
    Returns the Capabilities of this clusterer. Derived clusterers have to override this method to enable capabilities.
    Specified by:
      `getCapabilities` in interface `CapabilitiesHandler`
    Specified by:
      `getCapabilities` in interface `Clusterer`
    Overrides:
      `getCapabilities` in class `AbstractClusterer`
    Returns:
      the capabilities of this object
    See Also:
      - `Capabilities`

  - ### numberOfClusters

    public int numberOfClusters() throws Exception
    Description copied from class: `AbstractClusterer`
    Returns the number of clusters.
    Specified by:
      `numberOfClusters` in interface `Clusterer`
    Specified by:
      `numberOfClusters` in class `AbstractClusterer`
    Returns:
      the number of clusters generated for a training dataset.
    Throws:
      `Exception` - if number of clusters could not be returned successfully

  - ### listOptions

    public Enumeration<Option> listOptions()
    Returns an enumeration describing the available options.
    Specified by:
      `listOptions` in interface `OptionHandler`
    Overrides:
      `listOptions` in class `AbstractClusterer`
    Returns:
      an enumeration of all the available options.

  - ### setOptions

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

    Valid options are:

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

  - ### getOptions

    public String[] getOptions()
    Gets the current settings of the clusterer.
    Specified by:
      `getOptions` in interface `OptionHandler`
    Overrides:
      `getOptions` in class `AbstractClusterer`
    Returns:
      an array of strings suitable for passing to setOptions()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getDistanceIsBranchLength

    public boolean getDistanceIsBranchLength()

  - ### setDistanceIsBranchLength

    public void setDistanceIsBranchLength(boolean bDistanceIsHeight)

  - ### distanceIsBranchLengthTipText

    public String distanceIsBranchLengthTipText()

  - ### numClustersTipText

    public String numClustersTipText()
    Returns:
      a string to describe the NumClusters

  - ### printNewickTipText

    public String printNewickTipText()
    Returns:
      a string to describe the print Newick flag

  - ### distanceFunctionTipText

    public String distanceFunctionTipText()
    Returns:
      a string to describe the distance function

  - ### linkTypeTipText

    public String linkTypeTipText()
    Returns:
      a string to describe the Link type

  - ### globalInfo

    public String globalInfo()
    This will return a string describing the clusterer.
    Returns:
      The string.

  - ### main

    public static void main(String[] argv)

  - ### graph

    public String graph() throws Exception
    Description copied from interface: `Drawable`
    Returns a string that describes a graph representing the object. The string should be in XMLBIF ver. 0.3 format if the graph is a BayesNet, otherwise it should be in dotty format.
    Specified by:
      `graph` in interface `Drawable`
    Returns:
      the graph described by a string
    Throws:
      `Exception` - if the graph can't be computed

  - ### graphType

    public int graphType()
    Description copied from interface: `Drawable`
    Returns the type of graph representing the object.
    Specified by:
      `graphType` in interface `Drawable`
    Returns:
      the type of graph representing the object

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Overrides:
      `getRevision` in class `AbstractClusterer`
    Returns:
      the revision