Package adams.data.evaluator.instance
Class AbstractEvaluator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.evaluator.instance.AbstractEvaluator
-
- 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.ShallowCopySupporter<Evaluator>,adams.core.SizeOfHandler,Evaluator,Serializable,Comparable
- Direct Known Subclasses:
AbstractSerializableEvaluator,FakeEvaluator,NullEvaluator
public abstract class AbstractEvaluator extends adams.core.option.AbstractOptionHandler implements Evaluator
Abstract base class for evaluator handlingweka.core.Instanceobjects. Derived classes only have to override thecheck(Instance)method. Thereset()method can be used to reset an algorithms internal state, e.g., after setting options.- Version:
- $Revision: 2242 $
- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_METRICthe default metric.protected floatm_MissingEvaluationthe value to return in case no evaluation can be performed.
-
Constructor Summary
Constructors Constructor Description AbstractEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanbuild(weka.core.Instances data)Performs the check.intcompareTo(Object o)Compares this object with the specified object for order.voiddefineOptions()Adds options to the internal list of options.booleanequals(Object o)Returns whether the two objects are the same.HashMap<String,Float>evaluate(weka.core.Instance data)Performs the check.static AbstractEvaluatorforCommandLine(String cmdline)Instantiates the filter from the given commandline (i.e., classname and optional options).static AbstractEvaluatorforName(String classname, String[] options)Instantiates the filter with the given options.protected abstract floatgetDefaultMissingEvaluation()Returns the default value in case of missing evaluations.static String[]getEvaluators()Returns a list with classnames of filters.floatgetMissingEvaluation()Returns the replacement string for missing evaluations.StringmissingEvaluationTipText()Returns the tip text for this property.protected abstract booleanperformBuild(weka.core.Instances data)Builds the evaluator.protected FloatperformEvaluate(weka.core.Instance data)Performs the actual evaluation.protected HashMap<String,Float>performMultiEvaluate(weka.core.Instance data)Performs the actual evaluation, allowing return of multiple evaluation metrics.protected voidpreCheck(weka.core.Instance data)Performs the some pre-checks whether the data is actually suitable.protected voidpreCheck(weka.core.Instances data)Performs the some pre-checks whether the data is actually suitable.voidsetMissingEvaluation(float value)Sets the replacement string for missing evaluations.AbstractEvaluatorshallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.AbstractEvaluatorshallowCopy(boolean expand)Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
DEFAULT_METRIC
public static final String DEFAULT_METRIC
the default metric.- See Also:
- Constant Field Values
-
m_MissingEvaluation
protected float m_MissingEvaluation
the value to return in case no evaluation can be performed.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
getDefaultMissingEvaluation
protected abstract float getDefaultMissingEvaluation()
Returns the default value in case of missing evaluations.- Returns:
- the default value
-
setMissingEvaluation
public void setMissingEvaluation(float value)
Sets the replacement string for missing evaluations.- Specified by:
setMissingEvaluationin interfaceEvaluator- Parameters:
value- the replacement
-
getMissingEvaluation
public float getMissingEvaluation()
Returns the replacement string for missing evaluations.- Specified by:
getMissingEvaluationin interfaceEvaluator- Returns:
- the replacement
-
missingEvaluationTipText
public String missingEvaluationTipText()
Returns the tip text for this property.- Specified by:
missingEvaluationTipTextin interfaceEvaluator- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
preCheck
protected void preCheck(weka.core.Instance data)
Performs the some pre-checks whether the data is actually suitable. Data needs to be non-null and a class attribute defined.- Parameters:
data- the instance to check
-
preCheck
protected void preCheck(weka.core.Instances data)
Performs the some pre-checks whether the data is actually suitable.- Parameters:
data- the instance to check
-
performEvaluate
protected Float performEvaluate(weka.core.Instance data)
- Parameters:
data- the instance to check- Returns:
- evaluation metric,
m_MissingEvaluationin case the class value is missing
-
performMultiEvaluate
protected HashMap<String,Float> performMultiEvaluate(weka.core.Instance data)
Performs the actual evaluation, allowing return of multiple evaluation metrics.
Default implementation returns null.- Parameters:
data- the instance to check- Returns:
- evaluation metrics,
m_MissingEvaluationin case the class value is missing
-
performBuild
protected abstract boolean performBuild(weka.core.Instances data)
Builds the evaluator.- Parameters:
data- the instance to check- Returns:
- true if build successful
-
evaluate
public HashMap<String,Float> evaluate(weka.core.Instance data)
Performs the check. First attempts to retrieve data fromperformMultiEvaluate(Instance)and, if it receives null, callsperformEvaluate(Instance).- Specified by:
evaluatein interfaceEvaluator- Parameters:
data- the instance to check- Returns:
- evaluation metrics,
m_MissingEvaluationin case the class value is missing
-
build
public boolean build(weka.core.Instances data)
Performs the check.
-
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.- Specified by:
compareToin interfaceComparable- 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.
-
shallowCopy
public AbstractEvaluator shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceadams.core.ShallowCopySupporter<Evaluator>- Returns:
- the shallow copy
-
shallowCopy
public AbstractEvaluator shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceadams.core.ShallowCopySupporter<Evaluator>- 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 filters.- Returns:
- the filter classnames
-
forName
public static AbstractEvaluator forName(String classname, String[] options)
Instantiates the filter with the given options.- Parameters:
classname- the classname of the filter to instantiateoptions- the options for the filter- Returns:
- the instantiated filter or null if an error occurred
-
forCommandLine
public static AbstractEvaluator forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).- Parameters:
cmdline- the classname (and optional options) of the filter to instantiate- Returns:
- the instantiated filter or null if an error occurred
-
-