adams.data.weka.evaluator
Class AbstractInstanceEvaluator

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.data.weka.evaluator.AbstractInstanceEvaluator
All Implemented Interfaces:
CleanUpHandler, Debuggable, Destroyable, OptionHandler, SizeOfHandler, Serializable
Direct Known Subclasses:
AbstractDatasetInstanceEvaluator, NamedSetup, PassThrough

public abstract class AbstractInstanceEvaluator
extends AbstractOptionHandler
implements CleanUpHandler

Ancestor for evaluators that evaluate weka.core.Instance objects.

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

Field Summary
protected  boolean m_Initialized
          whether the evaluator got initialized.
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AbstractInstanceEvaluator()
           
 
Method Summary
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, debug, debug, debugLevelTipText, defineOptions, finishInit, getDebugLevel, getOptionManager, globalInfo, initialize, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 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 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 Destroyable
Overrides:
destroy in class AbstractOptionHandler


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