Package weka.clusterers
Class MakeDensityBasedClusterer
java.lang.Object
weka.clusterers.AbstractClusterer
weka.clusterers.AbstractDensityBasedClusterer
weka.clusterers.MakeDensityBasedClusterer
- All Implemented Interfaces:
Serializable
,Cloneable
,Clusterer
,DensityBasedClusterer
,NumberOfClustersRequestable
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,WeightedInstancesHandler
public class MakeDensityBasedClusterer
extends AbstractDensityBasedClusterer
implements NumberOfClustersRequestable, OptionHandler, WeightedInstancesHandler
Class for wrapping a Clusterer to make it return a
distribution and density. Fits normal distributions and discrete
distributions within each cluster produced by the wrapped clusterer. Supports
the NumberOfClustersRequestable interface only if the wrapped Clusterer does.
Valid options are:
-M <num> minimum allowable standard deviation for normal density computation (default 1e-6)
-W <clusterer name> Clusterer to wrap. (default weka.clusterers.SimpleKMeans)
Options specific to clusterer weka.clusterers.SimpleKMeans:
-N <num> number of clusters. (default 2).
-V Display std. deviations for centroids.
-M Replace missing values with mean/mode.
-S <num> Random number seed. (default 10)Options after "--" are passed on to the base clusterer.
- Version:
- $Revision: 15519 $
- Author:
- Richard Kirkby (rkirkby@cs.waikato.ac.nz), Mark Hall (mhall@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor.MakeDensityBasedClusterer
(Clusterer toWrap) Contructs a MakeDensityBasedClusterer wrapping a given Clusterer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildClusterer
(Instances data) Builds a clusterer for a set of instances.Returns the tip text for this propertydouble[]
Returns the cluster priors.Returns default capabilities of the clusterer (i.e., of the wrapper clusterer).Gets the clusterer being wrapped.double
Get the minimum allowable standard deviation.String[]
Gets the current settings of the clusterer.Returns the revision string.Returns a string describing classifierReturns an enumeration describing the available options..double[]
Computes the log of the conditional density (per cluster) for a given instance.static void
Main method for testing this class.Returns the tip text for this propertyint
Returns the number of clusters.void
setClusterer
(Clusterer toWrap) Sets the clusterer to wrap.void
setMinStdDev
(double m) Set the minimum value for standard deviation when calculating normal density.void
setNumClusters
(int n) Set the number of clusters to generate.void
setOptions
(String[] options) Parses a given list of options.toString()
Returns a description of the clusterer.Methods inherited from class weka.clusterers.AbstractDensityBasedClusterer
distributionForInstance, logDensityForInstance, logJointDensitiesForInstance, makeCopies
Methods inherited from class weka.clusterers.AbstractClusterer
clusterInstance, 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
Methods inherited from interface weka.clusterers.Clusterer
clusterInstance
-
Constructor Details
-
MakeDensityBasedClusterer
public MakeDensityBasedClusterer()Default constructor. -
MakeDensityBasedClusterer
Contructs a MakeDensityBasedClusterer wrapping a given Clusterer.- Parameters:
toWrap
- the clusterer to wrap around
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
setNumClusters
Set the number of clusters to generate.- Specified by:
setNumClusters
in interfaceNumberOfClustersRequestable
- Parameters:
n
- the number of clusters to generate- Throws:
Exception
- if the wrapped clusterer has not been set, or if the wrapped clusterer does not implement this facility.
-
getCapabilities
Returns default capabilities of the clusterer (i.e., of the wrapper clusterer).- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Specified by:
getCapabilities
in interfaceClusterer
- Overrides:
getCapabilities
in classAbstractClusterer
- Returns:
- the capabilities of this clusterer
- See Also:
-
buildClusterer
Builds a clusterer for a set of instances.- Specified by:
buildClusterer
in interfaceClusterer
- Specified by:
buildClusterer
in classAbstractClusterer
- Parameters:
data
- the instances to train the clusterer with- Throws:
Exception
- if the clusterer hasn't been set or something goes wrong
-
clusterPriors
public double[] clusterPriors()Returns the cluster priors.- Specified by:
clusterPriors
in interfaceDensityBasedClusterer
- Specified by:
clusterPriors
in classAbstractDensityBasedClusterer
- Returns:
- the cluster priors
-
logDensityPerClusterForInstance
Computes the log of the conditional density (per cluster) for a given instance.- Specified by:
logDensityPerClusterForInstance
in interfaceDensityBasedClusterer
- Specified by:
logDensityPerClusterForInstance
in classAbstractDensityBasedClusterer
- Parameters:
inst
- the instance to compute the density for- Returns:
- an array containing the estimated densities
- Throws:
Exception
- if the density could not be computed successfully
-
numberOfClusters
Returns the number of clusters.- Specified by:
numberOfClusters
in interfaceClusterer
- Specified by:
numberOfClusters
in classAbstractClusterer
- Returns:
- the number of clusters generated for a training dataset.
- Throws:
Exception
- if number of clusters could not be returned successfully
-
toString
Returns a description of the clusterer. -
clustererTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setClusterer
Sets the clusterer to wrap.- Parameters:
toWrap
- the clusterer
-
getClusterer
Gets the clusterer being wrapped.- Returns:
- the clusterer
-
minStdDevTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setMinStdDev
public void setMinStdDev(double m) Set the minimum value for standard deviation when calculating normal density. Reducing this value can help prevent arithmetic overflow resulting from multiplying large densities (arising from small standard deviations) when there are many singleton or near singleton values.- Parameters:
m
- minimum value for standard deviation
-
getMinStdDev
public double getMinStdDev()Get the minimum allowable standard deviation.- Returns:
- the minumum allowable standard deviation
-
listOptions
Returns an enumeration describing the available options..- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classAbstractClusterer
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-M <num> minimum allowable standard deviation for normal density computation (default 1e-6)
-W <clusterer name> Clusterer to wrap. (default weka.clusterers.SimpleKMeans)
Options specific to clusterer weka.clusterers.SimpleKMeans:
-N <num> number of clusters. (default 2).
-V Display std. deviations for centroids.
-M Replace missing values with mean/mode.
-S <num> Random number seed. (default 10)
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classAbstractClusterer
- 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:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classAbstractClusterer
- Returns:
- an array of strings suitable for passing to setOptions()
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractClusterer
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv
- the options
-