Package adams.flow.transformer
Class WekaReorderAttributesToReference
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.transformer.AbstractTransformer
-
- adams.flow.transformer.WekaReorderAttributesToReference
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LenientModeSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,VariableChangeListener,Actor,DynamicInitializer,ErrorHandler,InputConsumer,OptionalOneTimeInitializer,OutputProducer,Serializable,Comparable
public class WekaReorderAttributesToReference extends AbstractTransformer implements OptionalOneTimeInitializer, DynamicInitializer, LenientModeSupporter
Reorders the attributes of the Instance/Instances passing through according to the provided reference dataset (callable actor or reference file).
This ensures that the generated data always has the same structure as the reference dataset.
Input/output:
- accepts:
weka.core.Instance
weka.core.Instances
- generates:
weka.core.Instance
weka.core.Instances
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: WekaReorderAttributesToReference
-annotation <adams.core.base.BaseText> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors. default: false
-reference-file <adams.core.io.PlaceholderFile> (property: referenceFile) The reference dataset to load (when not pointing to a directory). default: ${CWD}-use-custom <boolean> (property: useCustomLoader) If set to true, then the custom loader will be used for loading the data. default: false
-loader <weka.core.converters.AbstractFileLoader> (property: customLoader) The custom loader to use if enabled. default: weka.core.converters.ArffLoader
-reference-actor <adams.flow.core.CallableActorReference> (property: referenceActor) The callable actor to use for obtaining the reference dataset in case reference file points to a directory. default: unknown
-on-the-fly <boolean> (property: onTheFly) If set to true, the reference file is not required to be present at set up time (eg if built on the fly), only at execution time. default: false
-init-once <boolean> (property: initializeOnce) If set to true, then the internal reorder filter will get initialized only with the first batch of data; otherwise every time data gets passed through. default: false
-lenient <boolean> (property: lenient) If set to true, attributes from the reference data that are missing in the incoming data get tolerated. default: false
-keep <boolean> (property: keepRelationName) If set to true, then the filter won't change the relation name of the incoming dataset. default: false
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringBACKUP_REFERENCEthe key for storing the reference dataset in the backup.static StringBACKUP_REORDERthe key for storing the reorder filter in the backup.protected weka.core.converters.AbstractFileLoaderm_CustomLoaderthe custom loader.protected booleanm_InitializeOncewhether to initialize filter only with the first batch.protected booleanm_KeepRelationNamewhether to keep the incoming relation name.protected booleanm_Lenientwhether to tolerate attributes that are not present in the incoming data.protected booleanm_OnTheFlywhether the dataset gets generated on the fly and might not be available at setUp time.protected weka.core.Instancesm_Referencethe reference dataset.protected CallableActorReferencem_ReferenceActorthe callable actor to get the reference data from.protected PlaceholderFilem_ReferenceFilethe reference dataset to load.protected weka.filters.MultiFilterm_Reorderthe reorder filter to use.protected booleanm_UseCustomLoaderwhether to use a custom converter.-
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description WekaReorderAttributesToReference()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.protected Hashtable<String,Object>backupState()Backs up the current state of the actor before update the variables.StringcustomLoaderTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.Class[]generates()Returns the class of objects that it generates.weka.core.converters.AbstractFileLoadergetCustomLoader()Returns the custom loader in use.booleangetInitializeOnce()Returns whether the internal reorder filter gets initialized only with the first batch.booleangetKeepRelationName()Returns whether the filter doesn't change the relation name.booleangetLenient()Returns whether to tolerate attributes that are missing in the incoming data.booleangetOnTheFly()Returns whether the reference file gets built on the fly and might not be present at start up time.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.CallableActorReferencegetReferenceActor()Returns the callable actor to obtain the reference dataset from if reference file is pointing to a directory.PlaceholderFilegetReferenceFile()Returns the file to load the reference dataset from.booleangetUseCustomLoader()Returns whether a custom loader is used or not.StringglobalInfo()Returns a string describing the object.StringinitializeOnceTipText()Returns the tip text for this property.StringkeepRelationNameTipText()Returns the tip text for this property.StringlenientTipText()Returns the tip text for this property.StringonTheFlyTipText()Returns the tip text for this property.protected voidpruneBackup()Removes entries from the backup.StringreferenceActorTipText()Returns the tip text for this property.StringreferenceFileTipText()Returns the tip text for this property.protected voidreset()Resets the actor.protected voidrestoreState(Hashtable<String,Object> state)Restores the state of the actor before the variables got updated.voidsetCustomLoader(weka.core.converters.AbstractFileLoader value)Sets the custom loader to use.voidsetInitializeOnce(boolean value)Sets whether the internal reorder filter gets initialized only with the first batch.voidsetKeepRelationName(boolean value)Sets whether the filter doesn't change the relation name.voidsetLenient(boolean value)Sets whether to tolerate attributes that are missing in the incoming data.voidsetOnTheFly(boolean value)Sets whether the reference file gets built on the fly and might not be present at start up time.voidsetReferenceActor(CallableActorReference value)Sets the callable actor to obtain the reference dataset from if reference file is pointing to a directory.voidsetReferenceFile(PlaceholderFile value)Sets the file to load the reference dataset from.StringsetUp()Initializes the item for flow execution.protected StringsetUpReference()Loads the reference data.voidsetUseCustomLoader(boolean value)Sets whether to use a custom loader or not.StringuseCustomLoaderTipText()Returns the tip text for this property.-
Methods inherited from class adams.flow.transformer.AbstractTransformer
currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, wrapUp
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged, wrapUp
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
BACKUP_REFERENCE
public static final String BACKUP_REFERENCE
the key for storing the reference dataset in the backup.- See Also:
- Constant Field Values
-
BACKUP_REORDER
public static final String BACKUP_REORDER
the key for storing the reorder filter in the backup.- See Also:
- Constant Field Values
-
m_ReferenceFile
protected PlaceholderFile m_ReferenceFile
the reference dataset to load.
-
m_UseCustomLoader
protected boolean m_UseCustomLoader
whether to use a custom converter.
-
m_CustomLoader
protected weka.core.converters.AbstractFileLoader m_CustomLoader
the custom loader.
-
m_ReferenceActor
protected CallableActorReference m_ReferenceActor
the callable actor to get the reference data from.
-
m_Reference
protected weka.core.Instances m_Reference
the reference dataset.
-
m_OnTheFly
protected boolean m_OnTheFly
whether the dataset gets generated on the fly and might not be available at setUp time.
-
m_InitializeOnce
protected boolean m_InitializeOnce
whether to initialize filter only with the first batch.
-
m_Lenient
protected boolean m_Lenient
whether to tolerate attributes that are not present in the incoming data.
-
m_KeepRelationName
protected boolean m_KeepRelationName
whether to keep the incoming relation name.
-
m_Reorder
protected weka.filters.MultiFilter m_Reorder
the reorder filter to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActor
-
reset
protected void reset()
Resets the actor.- Overrides:
resetin classAbstractActor
-
setReferenceFile
public void setReferenceFile(PlaceholderFile value)
Sets the file to load the reference dataset from.- Parameters:
value- the reference file
-
getReferenceFile
public PlaceholderFile getReferenceFile()
Returns the file to load the reference dataset from.- Returns:
- the reference file
-
referenceFileTipText
public String referenceFileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseCustomLoader
public void setUseCustomLoader(boolean value)
Sets whether to use a custom loader or not.- Parameters:
value- if true then the custom loader will be used
-
getUseCustomLoader
public boolean getUseCustomLoader()
Returns whether a custom loader is used or not.- Returns:
- true if a custom loader is used
-
useCustomLoaderTipText
public String useCustomLoaderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCustomLoader
public void setCustomLoader(weka.core.converters.AbstractFileLoader value)
Sets the custom loader to use.- Parameters:
value- the custom loader
-
getCustomLoader
public weka.core.converters.AbstractFileLoader getCustomLoader()
Returns the custom loader in use.- Returns:
- the custom loader
-
customLoaderTipText
public String customLoaderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setReferenceActor
public void setReferenceActor(CallableActorReference value)
Sets the callable actor to obtain the reference dataset from if reference file is pointing to a directory.- Parameters:
value- the actor reference
-
getReferenceActor
public CallableActorReference getReferenceActor()
Returns the callable actor to obtain the reference dataset from if reference file is pointing to a directory.- Returns:
- the actor reference
-
referenceActorTipText
public String referenceActorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOnTheFly
public void setOnTheFly(boolean value)
Sets whether the reference file gets built on the fly and might not be present at start up time.- Specified by:
setOnTheFlyin interfaceDynamicInitializer- Parameters:
value- if true then the reference does not have to be present at start up time
-
getOnTheFly
public boolean getOnTheFly()
Returns whether the reference file gets built on the fly and might not be present at start up time.- Specified by:
getOnTheFlyin interfaceDynamicInitializer- Returns:
- true if the reference is not necessarily present at start up time
-
onTheFlyTipText
public String onTheFlyTipText()
Returns the tip text for this property.- Specified by:
onTheFlyTipTextin interfaceDynamicInitializer- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setInitializeOnce
public void setInitializeOnce(boolean value)
Sets whether the internal reorder filter gets initialized only with the first batch.- Specified by:
setInitializeOncein interfaceOptionalOneTimeInitializer- Parameters:
value- true if the filter gets only initialized once
-
getInitializeOnce
public boolean getInitializeOnce()
Returns whether the internal reorder filter gets initialized only with the first batch.- Specified by:
getInitializeOncein interfaceOptionalOneTimeInitializer- Returns:
- true if the filter gets only initialized once
-
initializeOnceTipText
public String initializeOnceTipText()
Returns the tip text for this property.- Specified by:
initializeOnceTipTextin interfaceOptionalOneTimeInitializer- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLenient
public void setLenient(boolean value)
Sets whether to tolerate attributes that are missing in the incoming data.- Specified by:
setLenientin interfaceLenientModeSupporter- Parameters:
value- true if to tolerate unknown attributes
-
getLenient
public boolean getLenient()
Returns whether to tolerate attributes that are missing in the incoming data.- Specified by:
getLenientin interfaceLenientModeSupporter- Returns:
- true if to tolerate unknown attributes
-
lenientTipText
public String lenientTipText()
Returns the tip text for this property.- Specified by:
lenientTipTextin interfaceLenientModeSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setKeepRelationName
public void setKeepRelationName(boolean value)
Sets whether the filter doesn't change the relation name.- Parameters:
value- true if the filter won't change the relation name
-
getKeepRelationName
public boolean getKeepRelationName()
Returns whether the filter doesn't change the relation name.- Returns:
- true if the filter doesn't change the relation name
-
keepRelationNameTipText
public String keepRelationNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- Returns:
- null if no info available, otherwise short string
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceInputConsumer- Returns:
- the Class of objects that can be processed
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generatesin interfaceOutputProducer- Returns:
- the Class of the generated tokens
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackupin classAbstractActor- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupStatein classAbstractTransformer- Returns:
- the backup
- See Also:
AbstractActor.updateVariables(),AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreStatein classAbstractTransformer- Parameters:
state- the backup of the state to restore from- See Also:
AbstractActor.updateVariables(),AbstractActor.backupState()
-
setUpReference
protected String setUpReference()
Loads the reference data.- Returns:
- null if everything worked, otherwise an error message
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
-