Package adams.data.featuregenerator
Class AbstractFeatureGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.featuregenerator.AbstractFeatureGenerator
-
- All Implemented Interfaces:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.ShallowCopySupporter<AbstractFeatureGenerator>
,adams.core.SizeOfHandler
,Serializable
,Comparable
- Direct Known Subclasses:
AbstractDatabaseConnectionFeatureGenerator
,Max
,Mean
,Median
,Min
,PassThrough
public abstract class AbstractFeatureGenerator extends adams.core.option.AbstractOptionHandler implements Comparable, adams.core.ShallowCopySupporter<AbstractFeatureGenerator>
Abstract base class for feature generators.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Prefix
the prefix for the feature fields.static String
PREFIX_FEATURE
the default prefix for the feature fields.
-
Constructor Summary
Constructors Constructor Description AbstractFeatureGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Double
addFeature(Heatmap data, double value)
Adds the specified feature.protected Double
addFeature(Heatmap data, String suffix, double value)
Adds the specified feature.protected void
checkData(Heatmap data)
The default implementation only checks whether there is any data set.void
cleanUp()
Cleans up data structures, frees up memory.int
compareTo(Object o)
Compares this object with the specified object for order.void
defineOptions()
Adds options to the internal list of options.boolean
equals(Object o)
Returns whether the two objects are the same.static AbstractFeatureGenerator
forCommandLine(String cmdline)
Instantiates the generator from the given commandline (i.e., classname and optional options).static AbstractFeatureGenerator
forName(String classname, String[] options)
Instantiates the generator with the given options.Heatmap
generate(Heatmap data)
Generates the features and adds them to the report.protected String
getDefaultPrefix()
Returns the default prefix for the generated features.static String[]
getGenerators()
Returns a list with classnames of generators.String
getPrefix()
Returns the prefix in use for the generated features.String
prefixTipText()
Returns the tip text for this property.protected abstract Heatmap
processData(Heatmap data)
Performs the actual feature generation.protected void
reset()
Resets the generator.void
setPrefix(String value)
Sets the prefix to use for the generated features.AbstractFeatureGenerator
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractFeatureGenerator
shallowCopy(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
-
PREFIX_FEATURE
public static final String PREFIX_FEATURE
the default prefix for the feature fields.- See Also:
- Constant Field Values
-
m_Prefix
protected String m_Prefix
the prefix for the feature fields.
-
-
Method Detail
-
reset
protected void reset()
Resets the generator. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Overrides:
reset
in classadams.core.option.AbstractOptionHandler
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
getDefaultPrefix
protected String getDefaultPrefix()
Returns the default prefix for the generated features.- Returns:
- the default prefix
-
setPrefix
public void setPrefix(String value)
Sets the prefix to use for the generated features.- Parameters:
value
- the prefix to use
-
getPrefix
public String getPrefix()
Returns the prefix in use for the generated features.- Returns:
- the prefix in use
-
prefixTipText
public String prefixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
-
generate
public Heatmap generate(Heatmap data)
Generates the features and adds them to the report.- Parameters:
data
- the data to process- Returns:
- the processed data
-
checkData
protected void checkData(Heatmap data)
The default implementation only checks whether there is any data set.- Parameters:
data
- the data to process
-
addFeature
protected Double addFeature(Heatmap data, double value)
Adds the specified feature. Uses the class name (without packages) as feature suffix.- Parameters:
data
- the heatmap to add the feature tovalue
- the value of the feature- Returns:
- the previous value for this feature if any, otherwise null
-
addFeature
protected Double addFeature(Heatmap data, String suffix, double value)
Adds the specified feature. Uses an explicit suffix for the feature.- Parameters:
data
- the heatmap to add the feature tosuffix
- the suffix of the featurevalue
- the value of the feature- Returns:
- the previous value for this feature if any, otherwise null
-
processData
protected abstract Heatmap processData(Heatmap data)
Performs the actual feature generation.- Parameters:
data
- the data to process- Returns:
- the processed data
-
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:
compareTo
in 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 AbstractFeatureGenerator shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractFeatureGenerator>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractFeatureGenerator shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractFeatureGenerator>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getGenerators
public static String[] getGenerators()
Returns a list with classnames of generators.- Returns:
- the generator classnames
-
forName
public static AbstractFeatureGenerator forName(String classname, String[] options)
Instantiates the generator with the given options.- Parameters:
classname
- the classname of the generator to instantiateoptions
- the options for the generator- Returns:
- the instantiated generator or null if an error occurred
-
forCommandLine
public static AbstractFeatureGenerator forCommandLine(String cmdline)
Instantiates the generator from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the generator to instantiate- Returns:
- the instantiated generator or null if an error occurred
-
-