Class MOAClassification

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.io.ModelFileHandler, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<adams.flow.condition.bool.BooleanCondition>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.flow.condition.bool.BooleanCondition, adams.flow.condition.bool.IndexedBooleanCondition, Serializable

    public class MOAClassification
    extends adams.flow.condition.bool.AbstractBooleanCondition
    implements adams.flow.condition.bool.IndexedBooleanCondition, adams.core.io.ModelFileHandler
    Uses the index of the classification, i.e., the predicted label, as index of the switch

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -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.CallableActorReference> (property: modelActor)
        The callable actor to use for obtaining the model in case serialized model 
        file points to a directory.
        default: 
     
    -on-the-fly <boolean> (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.
        default: false
     
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected moa.classifiers.AbstractClassifier m_Model
      the model that was loaded from the model file.
      protected adams.flow.core.CallableActorReference m_ModelActor
      the callable actor to get the model from.
      protected adams.core.io.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_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Class[] accepts()
      Returns the class that the consumer accepts.
      void defineOptions()
      Adds options to the internal list of options.
      protected boolean doEvaluate​(adams.flow.core.Actor owner, adams.flow.core.Token token)
      Performs the actual evaluation.
      int getCaseIndex​(adams.flow.core.Actor owner, adams.flow.core.Token token)
      Returns the index of the case that should get executed.
      int getDefaultCaseIndex​(adams.flow.core.Actor owner, adams.flow.core.Token token)
      Returns the index of the default case.
      adams.flow.core.CallableActorReference getModelActor()
      Returns the callable actor to obtain the model from if model file is pointing to a directory.
      adams.core.io.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​(adams.flow.core.CallableActorReference value)
      Sets the callable actor to obtain the model from if model file is pointing to a directory.
      void setModelFile​(adams.core.io.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​(adams.flow.core.Actor owner)
      Initializes the item for flow execution.
      protected String setUpModel​(adams.flow.core.Actor owner)
      Loads the model from the model file.
      • Methods inherited from class adams.flow.condition.bool.AbstractBooleanCondition

        evaluate, preEvaluate, shallowCopy, shallowCopy, stopExecution
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.flow.condition.bool.BooleanCondition

        evaluate, shallowCopy, shallowCopy, stopExecution
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Field Detail

      • m_ModelFile

        protected adams.core.io.PlaceholderFile m_ModelFile
        the serialized model to load.
      • m_ModelActor

        protected adams.flow.core.CallableActorReference m_ModelActor
        the callable actor to get the model from.
      • m_Model

        protected moa.classifiers.AbstractClassifier 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

      • MOAClassification

        public MOAClassification()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.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:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setModelFile

        public void setModelFile​(adams.core.io.PlaceholderFile value)
        Sets the file to load the model from.
        Specified by:
        setModelFile in interface adams.core.io.ModelFileHandler
        Parameters:
        value - the model file
      • getModelFile

        public adams.core.io.PlaceholderFile getModelFile()
        Returns the file to load the model from.
        Specified by:
        getModelFile in interface adams.core.io.ModelFileHandler
        Returns:
        the model file
      • modelFileTipText

        public String modelFileTipText()
        Returns the tip text for this property.
        Specified by:
        modelFileTipText in interface adams.core.io.ModelFileHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setModelActor

        public void setModelActor​(adams.flow.core.CallableActorReference value)
        Sets the callable actor to obtain the model from if model file is pointing to a directory.
        Parameters:
        value - the actor reference
      • getModelActor

        public adams.flow.core.CallableActorReference getModelActor()
        Returns the callable 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 adams.flow.condition.bool.BooleanCondition
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Specified by:
        getQuickInfo in class adams.flow.condition.bool.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 adams.flow.condition.bool.BooleanCondition
        Specified by:
        accepts in class adams.flow.condition.bool.AbstractBooleanCondition
        Returns:
        Unknown
      • setUpModel

        protected String setUpModel​(adams.flow.core.Actor 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​(adams.flow.core.Actor owner)
        Initializes the item for flow execution.
        Specified by:
        setUp in interface adams.flow.condition.bool.BooleanCondition
        Overrides:
        setUp in class adams.flow.condition.bool.AbstractBooleanCondition
        Parameters:
        owner - the actor this condition belongs to
        Returns:
        null if everything is fine, otherwise error message
      • doEvaluate

        protected boolean doEvaluate​(adams.flow.core.Actor owner,
                                     adams.flow.core.Token token)
        Performs the actual evaluation.
        Specified by:
        doEvaluate in class adams.flow.condition.bool.AbstractBooleanCondition
        Parameters:
        owner - the owning actor
        token - the current token passing through
        Returns:
        the result of the evaluation
      • getCaseIndex

        public int getCaseIndex​(adams.flow.core.Actor owner,
                                adams.flow.core.Token token)
        Returns the index of the case that should get executed.
        Specified by:
        getCaseIndex in interface adams.flow.condition.bool.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​(adams.flow.core.Actor owner,
                                       adams.flow.core.Token token)
        Returns the index of the default case.
        Specified by:
        getDefaultCaseIndex in interface adams.flow.condition.bool.IndexedBooleanCondition
        Parameters:
        owner - the owning actor
        token - the current token passing through the actor
        Returns:
        the index, -1 if not available