adams.flow.transformer
Class AbstractProcessWekaInstanceWithModel<T>

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.transformer.AbstractTransformer
                  extended by adams.flow.transformer.AbstractProcessWekaInstanceWithModel<T>
Type Parameters:
T - the type of model to use
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, VariableChangeListener, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable
Direct Known Subclasses:
WekaClassifying, WekaClustering

public abstract class AbstractProcessWekaInstanceWithModel<T>
extends AbstractTransformer

Ancestor for transformers that user models for processing Instance objects, e.g., classifiers making predictions.

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
static String BACKUP_MODEL
          the key for storing the current model in the backup.
protected  T m_Model
          the model that was loaded from the model file.
protected  GlobalActorReference m_ModelActor
          the global actor to get the model from.
protected  PlaceholderFile m_ModelFile
          the serialized model to load.
protected  boolean m_OnTheFly
          whether the model gets built on the fly and might not be present at the start.
 
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
 
Fields inherited from class adams.flow.core.AbstractActor
FILE_EXTENSION, FILE_EXTENSION_GZ, m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AbstractProcessWekaInstanceWithModel()
           
 
Method Summary
 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.
 void defineOptions()
          Adds options to the internal list of options.
protected  String doExecute()
          Executes the flow item.
abstract  Class[] generates()
          Returns the class of objects that it generates.
 GlobalActorReference getModelActor()
          Returns the global actor to obtain the model from if model file is pointing to a directory.
 PlaceholderFile getModelFile()
          Returns the file to load the model from.
 boolean getOnTheFly()
          Returns whether the model file gets built on the fly and might not be present at start up time.
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 String modelActorTipText()
          Returns the tip text for this property.
 String modelFileTipText()
          Returns the tip text for this property.
 String onTheFlyTipText()
          Returns the tip text for this property.
protected abstract  Token processInstance(weka.core.Instance inst)
          Processes the instance and generates the output token.
protected  void pruneBackup()
          Removes entries from the backup.
protected  void restoreState(Hashtable<String,Object> state)
          Restores the state of the actor before the variables got updated.
 void setModelActor(GlobalActorReference value)
          Sets the global actor to obtain the model from if model file is pointing to a directory.
 void setModelFile(PlaceholderFile value)
          Sets the file to load the model from.
 void setOnTheFly(boolean value)
          Sets whether the model file gets built on the fly and might not be present at start up time.
 String setUp()
          Initializes the item for flow execution.
protected  String setUpModel()
          Loads the model from the model file.
 void wrapUp()
          Cleans up after the execution has finished.
 
Methods inherited from class adams.flow.transformer.AbstractTransformer
execute, hasPendingOutput, input, output, postExecute, reset
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, preExecute, pruneBackup, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, globalInfo, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BACKUP_MODEL

public static final String BACKUP_MODEL
the key for storing the current model in the backup.

See Also:
Constant Field Values

m_ModelFile

protected PlaceholderFile m_ModelFile
the serialized model to load.


m_ModelActor

protected GlobalActorReference m_ModelActor
the global actor to get the model from.


m_Model

protected T m_Model
the model that was loaded from the model file.


m_OnTheFly

protected boolean m_OnTheFly
whether the model gets built on the fly and might not be present at the start.

Constructor Detail

AbstractProcessWekaInstanceWithModel

public AbstractProcessWekaInstanceWithModel()
Method Detail

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractActor

setModelFile

public void setModelFile(PlaceholderFile value)
Sets the file to load the model from.

Parameters:
value - the model file

getModelFile

public PlaceholderFile getModelFile()
Returns the file to load the model from.

Returns:
the model file

modelFileTipText

public String modelFileTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setModelActor

public void setModelActor(GlobalActorReference value)
Sets the global actor to obtain the model from if model file is pointing to a directory.

Parameters:
value - the actor reference

getModelActor

public GlobalActorReference getModelActor()
Returns the global actor to obtain the model from if model file is pointing to a directory.

Returns:
the actor reference

modelActorTipText

public String modelActorTipText()
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 model file gets built on the fly and might not be present at start up time.

Parameters:
value - if true then the model does not have to be present at start up time

getOnTheFly

public boolean getOnTheFly()
Returns whether the model file gets built on the fly and might not be present at start up time.

Returns:
true if the model is not necessarily present at start up time

onTheFlyTipText

public String onTheFlyTipText()
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:
getQuickInfo in interface QuickInfoSupporter
Overrides:
getQuickInfo in class AbstractActor
Returns:
null if no info available, otherwise short string

accepts

public Class[] accepts()
Returns the class that the consumer accepts.

Returns:
weka.core.Instance.class

generates

public abstract Class[] generates()
Returns the class of objects that it generates.

Returns:
the classes

pruneBackup

protected void pruneBackup()
Removes entries from the backup.

Overrides:
pruneBackup in class AbstractActor

backupState

protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.

Overrides:
backupState in class AbstractTransformer
Returns:
the backup

restoreState

protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.

Overrides:
restoreState in class AbstractTransformer
Parameters:
state - the backup of the state to restore from

setUpModel

protected String setUpModel()
Loads the model from the model file.

Returns:
null if everything worked, otherwise an error message

setUp

public String setUp()
Initializes the item for flow execution.

Overrides:
setUp in class AbstractActor
Returns:
null if everything is fine, otherwise error message

processInstance

protected abstract Token processInstance(weka.core.Instance inst)
                                  throws Exception
Processes the instance and generates the output token.

Parameters:
inst - the instance to process
Returns:
the generated output token (e.g., container)
Throws:
Exception - if processing fails

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
null if everything is fine, otherwise error message

wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Overrides:
wrapUp in class AbstractTransformer


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.