Package adams.data.cleaner.instance
Class AbstractCleaner
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.cleaner.instance.AbstractCleaner
-
- All Implemented Interfaces:
adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.ShallowCopySupporter<AbstractCleaner>,adams.core.SizeOfHandler,adams.flow.core.FlowContextHandler,Serializable,Comparable
- Direct Known Subclasses:
AbstractDatabaseConnectionCleaner,AbstractSerializableCleaner,MinMax,PassThrough,RemoveOutliers
public abstract class AbstractCleaner extends adams.core.option.AbstractOptionHandler implements Comparable, adams.core.ShallowCopySupporter<AbstractCleaner>, adams.flow.core.FlowContextHandler
Abstract base class for cleaners handlingweka.core.Instanceobjects. Derived classes only have to override thecheck(Instance)method. Thereset()method can be used to reset an algorithms internal state, e.g., after setting options.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.filters.Filterm_ActualPreFilterthe actual pre-filter to use.protected Stringm_CleanInstancesErrorfor storing error messages in case the cleaning of the initial Instances object failed.protected adams.flow.core.Actorm_FlowContextthe flow context.protected weka.filters.Filterm_PreFilterthe pre-filter to use.
-
Constructor Summary
Constructors Constructor Description AbstractCleaner()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Stringcheck(weka.core.Instance data)Performs the check.weka.core.Instancesclean(weka.core.Instances data)Performs the clean.intcompareTo(Object o)Compares this object with the specified object for order.voiddefineOptions()Adds options to the internal list of options.booleanequals(Object o)Returns whether the two objects are the same.static AbstractCleanerforCommandLine(String cmdline)Instantiates the filter from the given commandline (i.e., classname and optional options).static AbstractCleanerforName(String classname, String[] options)Instantiates the filter with the given options.static String[]getCleaners()Returns a list with classnames of filters.StringgetCleanInstancesError()Returns the error message that was recorded during cleaning the Instances object (if any).adams.flow.core.ActorgetFlowContext()Returns the flow context.weka.filters.FiltergetPreFilter()Returns the filter to use for pre-filtering the data.booleanhasCleanInstancesError()Checks whether there was an error during cleaning the Instances object.protected abstract StringperformCheck(weka.core.Instance data)Performs the actual check.protected abstract weka.core.InstancesperformClean(weka.core.Instances data)Performs the actual check.protected voidpreCheck(weka.core.Instance data)Performs the pre-checks whether the data is actually suitable.protected voidpreCheck(weka.core.Instances data)Performs the some pre-checks whether the data is actually suitable.protected weka.core.InstancepreFilter(weka.core.Instance data)Performs the filtering.protected weka.core.InstancespreFilter(weka.core.Instances data)Performs the filtering.StringpreFilterTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetFlowContext(adams.flow.core.Actor value)Sets the flow context.voidsetPreFilter(weka.filters.Filter value)Sets the filter to use for pre-filtering the data.AbstractCleanershallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.AbstractCleanershallowCopy(boolean expand)Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_CleanInstancesError
protected String m_CleanInstancesError
for storing error messages in case the cleaning of the initial Instances object failed.
-
m_PreFilter
protected weka.filters.Filter m_PreFilter
the pre-filter to use.
-
m_ActualPreFilter
protected weka.filters.Filter m_ActualPreFilter
the actual pre-filter to use.
-
m_FlowContext
protected transient adams.flow.core.Actor m_FlowContext
the flow context.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classadams.core.option.AbstractOptionHandler
-
setPreFilter
public void setPreFilter(weka.filters.Filter value)
Sets the filter to use for pre-filtering the data.- Parameters:
value- the filter
-
getPreFilter
public weka.filters.Filter getPreFilter()
Returns the filter to use for pre-filtering the data.- Returns:
- the filter
-
preFilterTipText
public String preFilterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFlowContext
public void setFlowContext(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceadams.flow.core.FlowContextHandler- Parameters:
value- the context
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context.- Specified by:
getFlowContextin interfaceadams.flow.core.FlowContextHandler- Returns:
- the context, null if not available
-
preCheck
protected void preCheck(weka.core.Instance data)
Performs the pre-checks whether the data is actually suitable.- Parameters:
data- the instance to check
-
preCheck
protected void preCheck(weka.core.Instances data)
Performs the some pre-checks whether the data is actually suitable.- Parameters:
data- the instances to clean
-
performCheck
protected abstract String performCheck(weka.core.Instance data)
Performs the actual check.- Parameters:
data- the instance to check- Returns:
- null if ok, otherwise error message
-
performClean
protected abstract weka.core.Instances performClean(weka.core.Instances data)
Performs the actual check.- Parameters:
data- the instance to check- Returns:
- null if ok, otherwise error message
-
preFilter
protected weka.core.Instances preFilter(weka.core.Instances data)
Performs the filtering.- Parameters:
data- the data to filter
-
preFilter
protected weka.core.Instance preFilter(weka.core.Instance data)
Performs the filtering.- Parameters:
data- the data to filter
-
check
public String check(weka.core.Instance data)
Performs the check.- Parameters:
data- the instance to check- Returns:
- null if ok, otherwise error message
-
clean
public weka.core.Instances clean(weka.core.Instances data)
Performs the clean.- Parameters:
data- the instances to clean- Returns:
- cleaned instances
-
hasCleanInstancesError
public boolean hasCleanInstancesError()
Checks whether there was an error during cleaning the Instances object.- Returns:
- true if there was an error
-
getCleanInstancesError
public String getCleanInstancesError()
Returns the error message that was recorded during cleaning the Instances object (if any).- Returns:
- the error message, null if none occurred
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareToin interfaceComparable- Parameters:
o- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public AbstractCleaner shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceadams.core.ShallowCopySupporter<AbstractCleaner>- Returns:
- the shallow copy
-
shallowCopy
public AbstractCleaner shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceadams.core.ShallowCopySupporter<AbstractCleaner>- Parameters:
expand- whether to expand variables to their current values- Returns:
- the shallow copy
-
getCleaners
public static String[] getCleaners()
Returns a list with classnames of filters.- Returns:
- the filter classnames
-
forName
public static AbstractCleaner forName(String classname, String[] options)
Instantiates the filter with the given options.- Parameters:
classname- the classname of the filter to instantiateoptions- the options for the filter- Returns:
- the instantiated filter or null if an error occurred
-
forCommandLine
public static AbstractCleaner forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).- Parameters:
cmdline- the classname (and optional options) of the filter to instantiate- Returns:
- the instantiated filter or null if an error occurred
-
-