adams.flow.condition.bool
Class WekaClassification

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.condition.bool.AbstractBooleanCondition
              extended by adams.flow.condition.bool.WekaClassification
All Implemented Interfaces:
Debuggable, Destroyable, OptionHandler, ShallowCopySupporter<BooleanCondition>, SizeOfHandler, BooleanCondition, IndexedBooleanCondition, Serializable

public class WekaClassification
extends AbstractBooleanCondition
implements IndexedBooleanCondition

Uses the index of the classification, i.e., the predicted label, as index of the switch

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to 
    the console (0 = off).
    default: 0
    minimum: 0
 
-model <adams.core.io.PlaceholderFile> (property: modelFile)
    The model file to load (when not pointing to a directory).
    default: ${CWD}
 
-model-actor <adams.flow.core.GlobalActorReference> (property: modelActor)
    The global actor to use for obtaining the model in case serialized model 
    file points to a directory.
    default: 
 
-on-the-fly (property: onTheFly)
    If set to true, the model file is not required to be present at set up time 
    (eg if built on the fly), only at execution time.
 

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

Field Summary
protected  weka.classifiers.Classifier 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.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
WekaClassification()
           
 
Method Summary
 Class[] accepts()
          Returns the class that the consumer accepts.
 void defineOptions()
          Adds options to the internal list of options.
protected  boolean doEvaluate(AbstractActor owner, Token token)
          Evaluates whether to executed the "then" or "else" branch.
 int getCaseIndex(AbstractActor owner, Token token)
          Returns the index of the case that should get executed.
 int getDefaultCaseIndex(AbstractActor owner, Token token)
          Returns the index of the default case.
 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 globalInfo()
          Returns a string describing the object.
 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.
 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(AbstractActor owner)
          Initializes the item for flow execution.
protected  String setUpModel(AbstractActor owner)
          Loads the model from the model file.
 
Methods inherited from class adams.flow.condition.bool.AbstractBooleanCondition
evaluate, preEvaluate, shallowCopy, shallowCopy
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.flow.condition.bool.BooleanCondition
evaluate, shallowCopy, shallowCopy
 

Field Detail

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 weka.classifiers.Classifier 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

WekaClassification

public WekaClassification()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

defineOptions

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

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

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 BooleanCondition
Specified by:
getQuickInfo in class AbstractBooleanCondition
Returns:
null if no info available, otherwise short string

accepts

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

Specified by:
accepts in interface BooleanCondition
Specified by:
accepts in class AbstractBooleanCondition
Returns:
Unknown

setUpModel

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

Parameters:
owner - the actor this condition belongs to
Returns:
null if everything worked, otherwise an error message

setUp

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

Specified by:
setUp in interface BooleanCondition
Overrides:
setUp in class AbstractBooleanCondition
Parameters:
owner - the actor this condition belongs to
Returns:
null if everything is fine, otherwise error message

doEvaluate

protected boolean doEvaluate(AbstractActor owner,
                             Token token)
Evaluates whether to executed the "then" or "else" branch.

Specified by:
doEvaluate in class AbstractBooleanCondition
Parameters:
owner - the owning IfThenElse actor
token - the current token passing through the IfThenElse actor
Returns:
true if data matches capabilities

getCaseIndex

public int getCaseIndex(AbstractActor owner,
                        Token token)
Returns the index of the case that should get executed.

Specified by:
getCaseIndex in interface IndexedBooleanCondition
Parameters:
owner - the owning actor
token - the current token passing through the actor
Returns:
the index, -1 if not available

getDefaultCaseIndex

public int getDefaultCaseIndex(AbstractActor owner,
                               Token token)
Returns the index of the default case.

Specified by:
getDefaultCaseIndex in interface IndexedBooleanCondition
Parameters:
owner - the owning actor
token - the current token passing through the actor
Returns:
the index, -1 if not available


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