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:
adams.core.AdditionalInformationHandler,adams.core.CleanUpHandler,adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.LenientModeSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.QuickInfoSupporter,adams.core.ShallowCopySupporter<adams.flow.core.Actor>,adams.core.SizeOfHandler,adams.core.Stoppable,adams.core.StoppableWithFeedback,adams.core.VariablesInspectionHandler,adams.event.VariableChangeListener,adams.flow.core.Actor,adams.flow.core.DynamicInitializer,adams.flow.core.ErrorHandler,adams.flow.core.InputConsumer,adams.flow.core.OptionalOneTimeInitializer,adams.flow.core.OutputProducer,Serializable,Comparable
public class WekaReorderAttributesToReference extends adams.flow.transformer.AbstractTransformer implements adams.flow.core.OptionalOneTimeInitializer, adams.flow.core.DynamicInitializer, adams.core.LenientModeSupporterReorders 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 adams.flow.core.CallableActorReferencem_ReferenceActorthe callable actor to get the reference data from.protected adams.core.io.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
-
-
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.adams.flow.core.CallableActorReferencegetReferenceActor()Returns the callable actor to obtain the reference dataset from if reference file is pointing to a directory.adams.core.io.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(adams.flow.core.CallableActorReference value)Sets the callable actor to obtain the reference dataset from if reference file is pointing to a directory.voidsetReferenceFile(adams.core.io.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
-
-
-
-
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 adams.core.io.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 adams.flow.core.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 interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.flow.core.AbstractActor
-
reset
protected void reset()
Resets the actor.- Overrides:
resetin classadams.flow.core.AbstractActor
-
setReferenceFile
public void setReferenceFile(adams.core.io.PlaceholderFile value)
Sets the file to load the reference dataset from.- Parameters:
value- the reference file
-
getReferenceFile
public adams.core.io.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(adams.flow.core.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 adams.flow.core.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 interfaceadams.flow.core.DynamicInitializer- 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 interfaceadams.flow.core.DynamicInitializer- 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 interfaceadams.flow.core.DynamicInitializer- 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 interfaceadams.flow.core.OptionalOneTimeInitializer- 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 interfaceadams.flow.core.OptionalOneTimeInitializer- Returns:
- true if the filter gets only initialized once
-
initializeOnceTipText
public String initializeOnceTipText()
Returns the tip text for this property.- Specified by:
initializeOnceTipTextin interfaceadams.flow.core.OptionalOneTimeInitializer- 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 interfaceadams.core.LenientModeSupporter- 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 interfaceadams.core.LenientModeSupporter- Returns:
- true if to tolerate unknown attributes
-
lenientTipText
public String lenientTipText()
Returns the tip text for this property.- Specified by:
lenientTipTextin interfaceadams.core.LenientModeSupporter- 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 interfaceadams.flow.core.Actor- Specified by:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Overrides:
getQuickInfoin classadams.flow.core.AbstractActor- Returns:
- null if no info available, otherwise short string
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceadams.flow.core.InputConsumer- Returns:
- the Class of objects that can be processed
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generatesin interfaceadams.flow.core.OutputProducer- Returns:
- the Class of the generated tokens
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackupin classadams.flow.core.AbstractActor
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupStatein classadams.flow.transformer.AbstractTransformer- Returns:
- the backup
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreStatein classadams.flow.transformer.AbstractTransformer- Parameters:
state- the backup of the state to restore from
-
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 interfaceadams.flow.core.Actor- Overrides:
setUpin classadams.flow.core.AbstractActor- Returns:
- null if everything is fine, otherwise error message
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classadams.flow.core.AbstractActor- Returns:
- null if everything is fine, otherwise error message
-
-