Class AbstractInstanceEvaluator

  • All Implemented Interfaces:
    adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable
    Direct Known Subclasses:
    AbstractDatasetInstanceEvaluator, PassThrough

    public abstract class AbstractInstanceEvaluator
    extends adams.core.option.AbstractOptionHandler
    implements adams.core.CleanUpHandler
    Ancestor for evaluators that evaluate weka.core.Instance objects.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_Initialized
      whether the evaluator got initialized.
      • 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 Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected String check​(weka.core.Instance inst)
      Peforms checks on the instance that is about to be evaluated.
      void cleanUp()
      Cleans up data structures, frees up memory.
      int compareTo​(Object o)
      Compares this object with the specified object for order.
      void destroy()
      Frees up memory in a "destructive" non-reversible way.
      protected abstract double doEvaluate​(weka.core.Instance inst)
      Performs the actual evaluation.
      boolean equals​(Object o)
      Returns whether the two objects are the same.
      double evaluate​(weka.core.Instance inst)
      Evaluates the given instance.
      static AbstractInstanceEvaluator forCommandLine​(String cmdline)
      Instantiates the evaluator from the given commandline (i.e., classname and optional options).
      static AbstractInstanceEvaluator forName​(String classname, String[] options)
      Instantiates the evaluator with the given options.
      static String[] getEvaluators()
      Returns a list with classnames of evaluators.
      protected void reset()
      Resets the scheme.
      protected String setUp()
      Performs necessary initializations before being able to evaluate.
      AbstractInstanceEvaluator shallowCopy()
      Returns a shallow copy of itself, i.e., based on the commandline options.
      AbstractInstanceEvaluator shallowCopy​(boolean expand)
      Returns a shallow copy of itself, i.e., based on the commandline options.
      • Methods inherited from class adams.core.option.AbstractOptionHandler

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

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Field Detail

      • m_Initialized

        protected boolean m_Initialized
        whether the evaluator got initialized.
    • Constructor Detail

      • AbstractInstanceEvaluator

        public AbstractInstanceEvaluator()
    • Method Detail

      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class adams.core.option.AbstractOptionHandler
      • setUp

        protected String setUp()
        Performs necessary initializations before being able to evaluate.

        Default implementation only returns null.
        Returns:
        null if everything fine, error message otherwise
      • check

        protected String check​(weka.core.Instance inst)
        Peforms checks on the instance that is about to be evaluated.

        Default implementation only checks whether class value is non-missing.
        Parameters:
        inst - the instance to evaluate
        Returns:
        null if Instance can be evaluated, error message otherwise
      • doEvaluate

        protected abstract double doEvaluate​(weka.core.Instance inst)
        Performs the actual evaluation.
        Parameters:
        inst - the instance to evaluate
        Returns:
        evaluation range, between 0 and 1 (0 = bad, 1 = good, -1 = if unable to evaluate)
      • evaluate

        public double evaluate​(weka.core.Instance inst)
        Evaluates the given instance.
        Parameters:
        inst - the instance to evaluate
        Returns:
        evaluation range, between 0 and 1 (0 = bad, 1 = good, -1 = if unable to evaluate)
      • compareTo

        public int compareTo​(Object o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

        Only compares the commandlines of the two objects.
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object o)
        Returns whether the two objects are the same.

        Only compares the commandlines of the two objects.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • shallowCopy

        public AbstractInstanceEvaluator shallowCopy()
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Returns:
        the shallow copy
      • shallowCopy

        public AbstractInstanceEvaluator shallowCopy​(boolean expand)
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Parameters:
        expand - whether to expand variables to their current values
        Returns:
        the shallow copy
      • getEvaluators

        public static String[] getEvaluators()
        Returns a list with classnames of evaluators.
        Returns:
        the evaluator classnames
      • forName

        public static AbstractInstanceEvaluator forName​(String classname,
                                                        String[] options)
        Instantiates the evaluator with the given options.
        Parameters:
        classname - the classname of the evaluator to instantiate
        options - the options for the evaluator
        Returns:
        the instantiated evaluator or null if an error occurred
      • forCommandLine

        public static AbstractInstanceEvaluator forCommandLine​(String cmdline)
        Instantiates the evaluator from the given commandline (i.e., classname and optional options).
        Parameters:
        cmdline - the classname (and optional options) of the evaluator to instantiate
        Returns:
        the instantiated evaluator or null if an error occurred
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.

        Default implementation does nothing.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
      • destroy

        public void destroy()
        Frees up memory in a "destructive" non-reversible way.

        Calls cleanUp() and cleans up the options.
        Specified by:
        destroy in interface adams.core.Destroyable
        Overrides:
        destroy in class adams.core.option.AbstractOptionHandler