Package weka.filters.supervised.instance
Class RHC
java.lang.Object
weka.filters.Filter
weka.filters.supervised.instance.RHC
- All Implemented Interfaces:
Serializable,weka.core.CapabilitiesHandler,weka.core.CapabilitiesIgnorer,weka.core.CommandlineRunnable,weka.core.OptionHandler,weka.core.RevisionHandler,weka.core.TechnicalInformationHandler,weka.filters.SupervisedFilter
public class RHC
extends weka.filters.Filter
implements weka.filters.SupervisedFilter, weka.core.OptionHandler, weka.core.TechnicalInformationHandler
RHC (Reduction through Homogeneous Clusters) is a non-parametric,
cluster-based prototype abstraction (data reduction) algorithm. It keeps
splitting the training set with k-Means until every cluster is homogeneous
(contains instances of a single class); the centroid of each homogeneous
cluster becomes a prototype of the condensed set. In every split, k is the
number of classes present in the cluster and the initial means are the
class centroids of that cluster.
Only the first batch (the training data) is reduced; subsequent batches pass through unchanged.
For more information see:
Stefanos Ougiaroglou, Georgios Evangelidis (2016). RHC: a non-parametric cluster-based data reduction for efficient k-NN classification. Pattern Analysis and Applications. 19(1):93-109. Valid options are:
Only the first batch (the training data) is reduced; subsequent batches pass through unchanged.
For more information see:
Stefanos Ougiaroglou, Georgios Evangelidis (2016). RHC: a non-parametric cluster-based data reduction for efficient k-NN classification. Pattern Analysis and Applications. 19(1):93-109. Valid options are:
-I <num> Maximum number of k-Means iterations per split. (default 100)
-V Print reduction statistics to standard error.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected weka.core.EuclideanDistancedistance function used by k-Means (class attribute is ignored).protected intmaximum number of k-Means iterations per split.protected intnumber of clusters processed (dequeue operations).protected intsize of the condensing set.protected intsize of the training set (after removing missing-class instances).protected booleanwhether to print statistics.Fields inherited from class weka.filters.Filter
m_Debug, m_DoNotCheckCapabilities, m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanSignify that this batch of input to the filter is finished.protected weka.core.InstanceComputes the (weighted) mean vector of a set of instances: mean for numeric/date attributes, mode for nominal ones (including the class).weka.core.CapabilitiesReturns the Capabilities of this filter.intintintString[]Gets the current settings of the filter.Returns the revision string.weka.core.TechnicalInformationReturns technical information about the algorithm.booleanReturns a string describing this filter.booleaninput(weka.core.Instance instance) Input an instance for filtering.Plain k-Means (Lloyd) starting from the given means.Enumeration<weka.core.Option> Returns an enumeration describing the available options.static voidMain method for testing this class.protected List<weka.core.Instance> reduce(weka.core.Instances data) The RHC algorithm.booleansetInputFormat(weka.core.Instances instanceInfo) Sets the format of the input instances.voidsetMaxIterations(int value) voidsetOptions(String[] options) Parses a given list of options.voidsetVerbose(boolean value) splitByClass(List<weka.core.Instance> c) Groups instances by class value (insertion order is preserved).Methods inherited from class weka.filters.Filter
batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
-
Field Details
-
m_MaxIterations
protected int m_MaxIterationsmaximum number of k-Means iterations per split. -
m_Verbose
protected boolean m_Verbosewhether to print statistics. -
m_NumTrainingInstances
protected int m_NumTrainingInstancessize of the training set (after removing missing-class instances). -
m_NumPrototypes
protected int m_NumPrototypessize of the condensing set. -
m_NumIterations
protected int m_NumIterationsnumber of clusters processed (dequeue operations). -
m_Distance
protected transient weka.core.EuclideanDistance m_Distancedistance function used by k-Means (class attribute is ignored).
-
-
Constructor Details
-
RHC
public RHC()
-
-
Method Details
-
globalInfo
Returns a string describing this filter.- Returns:
- a description of the filter suitable for displaying in the GUI
-
getTechnicalInformation
public weka.core.TechnicalInformation getTechnicalInformation()Returns technical information about the algorithm.- Specified by:
getTechnicalInformationin interfaceweka.core.TechnicalInformationHandler- Returns:
- the technical information
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classweka.filters.Filter- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options.- Specified by:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classweka.filters.Filter- 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 filter.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classweka.filters.Filter- Returns:
- an array of strings suitable for passing to setOptions
-
maxIterationsTipText
- Returns:
- tip text for the GUI
-
setMaxIterations
public void setMaxIterations(int value) - Parameters:
value- the maximum number of k-Means iterations (>= 1)
-
getMaxIterations
public int getMaxIterations()- Returns:
- the maximum number of k-Means iterations
-
verboseTipText
- Returns:
- tip text for the GUI
-
setVerbose
public void setVerbose(boolean value) - Parameters:
value- whether to print statistics
-
getVerbose
public boolean getVerbose()- Returns:
- whether statistics are printed
-
getNumTrainingInstances
public int getNumTrainingInstances()- Returns:
- the size of the last training set that was reduced
-
getNumPrototypes
public int getNumPrototypes()- Returns:
- the size of the last condensing set produced
-
getCapabilities
public weka.core.Capabilities getCapabilities()Returns the Capabilities of this filter.- Specified by:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Overrides:
getCapabilitiesin classweka.filters.Filter- Returns:
- the capabilities of this object
-
setInputFormat
Sets the format of the input instances.- Overrides:
setInputFormatin classweka.filters.Filter- Parameters:
instanceInfo- the input structure- Returns:
- true if the outputFormat may be collected immediately
- Throws:
Exception- if the input format can't be set successfully
-
input
public boolean input(weka.core.Instance instance) Input an instance for filtering. The first batch is buffered until batchFinished() is called; later batches pass through unchanged.- Overrides:
inputin classweka.filters.Filter- Parameters:
instance- the input instance- Returns:
- true if the filtered instance may now be collected with output().
- Throws:
IllegalStateException- if no input structure has been defined
-
batchFinished
Signify that this batch of input to the filter is finished. On the first batch the RHC reduction is performed.- Overrides:
batchFinishedin classweka.filters.Filter- Returns:
- true if there are instances pending output
- Throws:
Exception- if no input structure has been defined
-
reduce
The RHC algorithm.- Parameters:
data- the training set (no missing class values)- Returns:
- the condensing set (one prototype per homogeneous cluster)
-
splitByClass
Groups instances by class value (insertion order is preserved).- Parameters:
c- the instances- Returns:
- class value -> instances of that class
-
kMeans
protected List<List<weka.core.Instance>> kMeans(List<weka.core.Instance> c, List<weka.core.Instance> means, weka.core.Instances header) Plain k-Means (Lloyd) starting from the given means.- Parameters:
c- the instances to clustermeans- the initial meansheader- the dataset structure- Returns:
- the non-empty clusters
-
centroid
Computes the (weighted) mean vector of a set of instances: mean for numeric/date attributes, mode for nominal ones (including the class). Missing values are ignored; if all values are missing the result is missing.- Parameters:
members- the instancesheader- the dataset structure- Returns:
- a new instance holding the centroid
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceweka.core.RevisionHandler- Overrides:
getRevisionin classweka.filters.Filter- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv- should contain arguments to the filter: use -h for help
-