Package weka.clusterers
Class HierarchicalClusterer
java.lang.Object
weka.clusterers.AbstractClusterer
weka.clusterers.HierarchicalClusterer
- All Implemented Interfaces:
Serializable,Cloneable,Clusterer,CapabilitiesHandler,Drawable,OptionHandler,RevisionHandler
public class HierarchicalClusterer
extends AbstractClusterer
implements OptionHandler, CapabilitiesHandler, 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|ADJCOMLPETE|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: 11330 $
- Author:
- Remco Bouckaert (rrb@xm.co.nz, remco@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Field Summary
FieldsFields inherited from interface weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClusterer(Instances data) Generates a clusterer.intclusterInstance(Instance instance) Classifies a given instance.Returns the tip text for this propertydouble[]distributionForInstance(Instance instance) Predicts the cluster memberships for a given instance.Returns the Capabilities of this clusterer.booleangetDebug()Get whether debugging is turned on.booleanintString[]Gets the current settings of the clusterer.booleanReturns the revision string.This will return a string describing the clusterer.graph()Returns a string that describes a graph representing the object.intReturns the type of graph representing the object.Returns an enumeration describing the available options.static voidintReturns the number of clusters.voidsetDebug(boolean debug) Set debugging mode.voidsetDistanceFunction(DistanceFunction distanceFunction) voidsetDistanceIsBranchLength(boolean bDistanceIsHeight) voidsetLinkType(SelectedTag newLinkType) voidsetNumClusters(int nClusters) voidsetOptions(String[] options) Parses a given list of options.voidsetPrintNewick(boolean bPrintNewick) toString()Methods inherited from class weka.clusterers.AbstractClusterer
forName, makeCopies, makeCopy
-
Field Details
-
TAGS_LINK_TYPE
-
-
Constructor Details
-
HierarchicalClusterer
public HierarchicalClusterer()
-
-
Method Details
-
setNumClusters
public void setNumClusters(int nClusters) -
getNumClusters
public int getNumClusters() -
getDistanceFunction
-
setDistanceFunction
-
getPrintNewick
public boolean getPrintNewick() -
setPrintNewick
public void setPrintNewick(boolean bPrintNewick) -
setLinkType
-
getLinkType
-
buildClusterer
Description copied from class:AbstractClustererGenerates a clusterer. Has to initialize all fields of the clusterer that are not being set via options.- Specified by:
buildClustererin interfaceClusterer- Specified by:
buildClustererin classAbstractClusterer- Parameters:
data- set of instances serving as training data- Throws:
Exception- if the clusterer has not been generated successfully
-
clusterInstance
Description copied from class:AbstractClustererClassifies a given instance. Either this or distributionForInstance() needs to be implemented by subclasses.- Specified by:
clusterInstancein interfaceClusterer- Overrides:
clusterInstancein classAbstractClusterer- 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
Description copied from class:AbstractClustererPredicts the cluster memberships for a given instance. Either this or clusterInstance() needs to be implemented by subclasses.- Specified by:
distributionForInstancein interfaceClusterer- Overrides:
distributionForInstancein classAbstractClusterer- 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
Description copied from class:AbstractClustererReturns the Capabilities of this clusterer. Derived classifiers have to override this method to enable capabilities.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Specified by:
getCapabilitiesin interfaceClusterer- Overrides:
getCapabilitiesin classAbstractClusterer- Returns:
- the capabilities of this object
- See Also:
-
numberOfClusters
Description copied from class:AbstractClustererReturns the number of clusters.- Specified by:
numberOfClustersin interfaceClusterer- Specified by:
numberOfClustersin classAbstractClusterer- Returns:
- the number of clusters generated for a training dataset.
- Throws:
Exception- if number of clusters could not be returned successfully
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:- Specified by:
setOptionsin interfaceOptionHandler- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
Gets the current settings of the clusterer.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- an array of strings suitable for passing to setOptions()
-
toString
-
setDebug
public void setDebug(boolean debug) Set debugging mode.- Parameters:
debug- true if debug output should be printed
-
getDebug
public boolean getDebug()Get whether debugging is turned on.- Returns:
- true if debugging output is on
-
getDistanceIsBranchLength
public boolean getDistanceIsBranchLength() -
setDistanceIsBranchLength
public void setDistanceIsBranchLength(boolean bDistanceIsHeight) -
distanceIsBranchLengthTipText
-
debugTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
numClustersTipText
- Returns:
- a string to describe the NumClusters
-
printNewickTipText
- Returns:
- a string to describe the print Newick flag
-
distanceFunctionTipText
- Returns:
- a string to describe the distance function
-
linkTypeTipText
- Returns:
- a string to describe the Link type
-
globalInfo
This will return a string describing the clusterer.- Returns:
- The string.
-
main
-
graph
Description copied from interface:DrawableReturns 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. -
graphType
public int graphType()Description copied from interface:DrawableReturns the type of graph representing the object. -
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClusterer- Returns:
- the revision
-