Package adams.data.evaluator.instance
Class CrossValidatedNeighborHood
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.evaluator.instance.AbstractEvaluator
-
- adams.data.evaluator.instance.AbstractSerializableEvaluator
-
- adams.data.evaluator.instance.AbstractNearestNeighborBasedEvaluator
-
- adams.data.evaluator.instance.CrossValidatedNeighborHood
-
- 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.Randomizable
,adams.core.SerializableObject
,adams.core.ShallowCopySupporter<Evaluator>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,Evaluator
,WekaClassifierBasedEvaluator
,Serializable
,Comparable
public class CrossValidatedNeighborHood extends AbstractNearestNeighborBasedEvaluator implements adams.core.Randomizable, WekaClassifierBasedEvaluator, adams.core.StoppableWithFeedback
Evaluator that cross-validates the specified classifier on the neighborhood determined for the instance under evaluation. Outputs the specified measure as evaluation value.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-missing-evaluation <float> (property: missingEvaluation) The value to use as replacement for missing evaluations. default: NaN
-serialization-file <adams.core.io.PlaceholderFile> (property: serializationFile) The file to serialize the generated internal model to. default: ${CWD}
-override-serialized-file <boolean> (property: overrideSerializedFile) If set to true, then any serialized file will be ignored and the setup for serialization will be regenerated. default: false
-search <weka.core.neighboursearch.NearestNeighbourSearch> (property: search) The nearest neighbor search to use. default: weka.core.neighboursearch.LinearNNSearch -A \"weka.core.EuclideanDistance -R first-last\"
-classifier <weka.classifiers.Classifier> (property: classifier) The classifier to evaluate on the neighborhood. default: weka.classifiers.functions.LinearRegression -S 1 -C -R 1.0E-8 -num-decimal-places 4
-num-neighbors <int> (property: numNeighbors) The number of neighbors to use in the neighborhood. default: 100 minimum: 1
-folds <int> (property: folds) The number of folds to use for cross-validation; performs leave-one-out cross-validation if less than 2. default: 10 minimum: -1
-seed <long> (property: seed) The seed value for the cross-validation. default: 1
-statistic <NUMBER_CORRECT|NUMBER_INCORRECT|NUMBER_UNCLASSIFIED|PERCENT_CORRECT|PERCENT_INCORRECT|PERCENT_UNCLASSIFIED|KAPPA_STATISTIC|MEAN_ABSOLUTE_ERROR|ROOT_MEAN_SQUARED_ERROR|RELATIVE_ABSOLUTE_ERROR|ROOT_RELATIVE_SQUARED_ERROR|CORRELATION_COEFFICIENT|SF_PRIOR_ENTROPY|SF_SCHEME_ENTROPY|SF_ENTROPY_GAIN|SF_MEAN_PRIOR_ENTROPY|SF_MEAN_SCHEME_ENTROPY|SF_MEAN_ENTROPY_GAIN|KB_INFORMATION|KB_MEAN_INFORMATION|KB_RELATIVE_INFORMATION|TRUE_POSITIVE_RATE|NUM_TRUE_POSITIVES|FALSE_POSITIVE_RATE|NUM_FALSE_POSITIVES|TRUE_NEGATIVE_RATE|NUM_TRUE_NEGATIVES|FALSE_NEGATIVE_RATE|NUM_FALSE_NEGATIVES|IR_PRECISION|IR_RECALL|F_MEASURE|MATTHEWS_CORRELATION_COEFFICIENT|AREA_UNDER_ROC|AREA_UNDER_PRC|WEIGHTED_TRUE_POSITIVE_RATE|WEIGHTED_FALSE_POSITIVE_RATE|WEIGHTED_TRUE_NEGATIVE_RATE|WEIGHTED_FALSE_NEGATIVE_RATE|WEIGHTED_IR_PRECISION|WEIGHTED_IR_RECALL|WEIGHTED_F_MEASURE|WEIGHTED_MATTHEWS_CORRELATION_COEFFICIENT|WEIGHTED_AREA_UNDER_ROC|WEIGHTED_AREA_UNDER_PRC> (property: statistic) The statistic to use as evaluation output. default: ROOT_MEAN_SQUARED_ERROR
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.classifiers.Classifier
m_Classifier
the classifier to cross-validate.protected weka.classifiers.StoppableEvaluation
m_Evaluation
the current evaluation.protected int
m_Folds
the number of folds.protected int
m_NumNeighbors
the size of the neighborhood.protected long
m_Seed
the seed value.protected adams.flow.core.EvaluationStatistic
m_Statistic
the measure to output as evaluation.protected boolean
m_Stopped
whether the execution was stopped.-
Fields inherited from class adams.data.evaluator.instance.AbstractNearestNeighborBasedEvaluator
m_ActualSearch, m_Header, m_Search, m_TrainingData
-
Fields inherited from class adams.data.evaluator.instance.AbstractSerializableEvaluator
m_OverrideSerializationFile, m_SerializableObjectHelper, m_SerializationFile
-
Fields inherited from class adams.data.evaluator.instance.AbstractEvaluator
DEFAULT_METRIC, m_MissingEvaluation
-
-
Constructor Summary
Constructors Constructor Description CrossValidatedNeighborHood()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
classifierTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.String
foldsTipText()
Returns the tip text for this property.weka.classifiers.Classifier
getClassifier()
Returns the classifier in use.protected weka.classifiers.Classifier
getDefaultClassifier()
Returns the default classifier.protected weka.core.neighboursearch.NearestNeighbourSearch
getDefaultSearch()
Returns the default search algorithm to use.int
getFolds()
Returns the number of folds.int
getNumNeighbors()
Returns the number of neighbors to use in the neighborhood.long
getSeed()
Returns the seed value for cross-validation.adams.flow.core.EvaluationStatistic
getStatistic()
Returns the statistic used as evaluation output.String
globalInfo()
Returns a string describing the object.boolean
isStopped()
Whether the execution has been stopped.String
numNeighborsTipText()
Returns the tip text for this property.protected boolean
performBuild(weka.core.Instances data)
Builds the evaluator.protected Float
performEvaluate(weka.core.Instance data)
Performs the actual evaluation.Object[]
retrieveSerializationSetup()
Returns the member variables to serialize to a file.String
seedTipText()
Returns the tip text for this property.void
setClassifier(weka.classifiers.Classifier value)
Sets the classifier to use.void
setFolds(int value)
Sets the number of folds.void
setNumNeighbors(int value)
Sets the number of neighbors to use in the neighborhood.void
setSeed(long value)
Sets the seed value for cross-validation.void
setSerializationSetup(Object[] value)
Updates the member variables with the provided objects obtained from deserialization.void
setStatistic(adams.flow.core.EvaluationStatistic value)
Sets the statistic to use as evaluation output.String
statisticTipText()
Returns the tip text for this property.void
stopExecution()
Stops the execution.-
Methods inherited from class adams.data.evaluator.instance.AbstractNearestNeighborBasedEvaluator
cleanUp, getDefaultMissingEvaluation, getSearch, initSearch, initSerializationSetup, searchTipText, setSearch
-
Methods inherited from class adams.data.evaluator.instance.AbstractSerializableEvaluator
destroy, getOverrideSerializedFile, getSerializationFile, initialize, isSetupLoadedOrGenerated, overrideSerializedFileTipText, preCheck, reset, serializationFileTipText, setLoggingLevel, setOverrideSerializedFile, setSerializationFile, setSetupLoadedOrGenerated
-
Methods inherited from class adams.data.evaluator.instance.AbstractEvaluator
build, compareTo, equals, evaluate, forCommandLine, forName, getEvaluators, getMissingEvaluation, missingEvaluationTipText, performMultiEvaluate, preCheck, setMissingEvaluation, shallowCopy, shallowCopy
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface adams.data.evaluator.instance.Evaluator
build, evaluate, getMissingEvaluation, missingEvaluationTipText, setMissingEvaluation
-
-
-
-
Field Detail
-
m_NumNeighbors
protected int m_NumNeighbors
the size of the neighborhood.
-
m_Classifier
protected weka.classifiers.Classifier m_Classifier
the classifier to cross-validate.
-
m_Folds
protected int m_Folds
the number of folds.
-
m_Seed
protected long m_Seed
the seed value.
-
m_Statistic
protected adams.flow.core.EvaluationStatistic m_Statistic
the measure to output as evaluation.
-
m_Stopped
protected boolean m_Stopped
whether the execution was stopped.
-
m_Evaluation
protected transient weka.classifiers.StoppableEvaluation m_Evaluation
the current evaluation.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.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 interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classAbstractNearestNeighborBasedEvaluator
-
getDefaultSearch
protected weka.core.neighboursearch.NearestNeighbourSearch getDefaultSearch()
Returns the default search algorithm to use.- Specified by:
getDefaultSearch
in classAbstractNearestNeighborBasedEvaluator
- Returns:
- the default
-
setNumNeighbors
public void setNumNeighbors(int value)
Sets the number of neighbors to use in the neighborhood.- Parameters:
value
- the number of neighbors
-
getNumNeighbors
public int getNumNeighbors()
Returns the number of neighbors to use in the neighborhood.- Returns:
- the number of neighbors
-
numNeighborsTipText
public String numNeighborsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getDefaultClassifier
protected weka.classifiers.Classifier getDefaultClassifier()
Returns the default classifier.- Returns:
- the default
-
setClassifier
public void setClassifier(weka.classifiers.Classifier value)
Sets the classifier to use.- Specified by:
setClassifier
in interfaceWekaClassifierBasedEvaluator
- Parameters:
value
- the classifier
-
getClassifier
public weka.classifiers.Classifier getClassifier()
Returns the classifier in use.- Specified by:
getClassifier
in interfaceWekaClassifierBasedEvaluator
- Returns:
- the classifier
-
classifierTipText
public String classifierTipText()
Returns the tip text for this property.- Specified by:
classifierTipText
in interfaceWekaClassifierBasedEvaluator
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFolds
public void setFolds(int value)
Sets the number of folds.- Parameters:
value
- the number of folds, LOO if < 2
-
getFolds
public int getFolds()
Returns the number of folds.- Returns:
- the number of folds, LOO if < 2
-
foldsTipText
public String foldsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSeed
public void setSeed(long value)
Sets the seed value for cross-validation.- Specified by:
setSeed
in interfaceadams.core.Randomizable
- Parameters:
value
- the seed
-
getSeed
public long getSeed()
Returns the seed value for cross-validation.- Specified by:
getSeed
in interfaceadams.core.Randomizable
- Returns:
- the seed
-
seedTipText
public String seedTipText()
Returns the tip text for this property.- Specified by:
seedTipText
in interfaceadams.core.Randomizable
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setStatistic
public void setStatistic(adams.flow.core.EvaluationStatistic value)
Sets the statistic to use as evaluation output.- Parameters:
value
- the statistic
-
getStatistic
public adams.flow.core.EvaluationStatistic getStatistic()
Returns the statistic used as evaluation output.- Returns:
- the statistic
-
statisticTipText
public String statisticTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
retrieveSerializationSetup
public Object[] retrieveSerializationSetup()
Returns the member variables to serialize to a file.- Specified by:
retrieveSerializationSetup
in interfaceadams.core.SerializableObject
- Returns:
- the objects to serialize
-
setSerializationSetup
public void setSerializationSetup(Object[] value)
Updates the member variables with the provided objects obtained from deserialization.- Specified by:
setSerializationSetup
in interfaceadams.core.SerializableObject
- Parameters:
value
- the deserialized objects
-
performBuild
protected boolean performBuild(weka.core.Instances data)
Builds the evaluator.- Specified by:
performBuild
in classAbstractEvaluator
- Parameters:
data
- the instance to check- Returns:
- always true
-
performEvaluate
protected Float performEvaluate(weka.core.Instance data)
Performs the actual evaluation.- Overrides:
performEvaluate
in classAbstractEvaluator
- Parameters:
data
- the instance to check- Returns:
- evaluation metric,
AbstractEvaluator.m_MissingEvaluation
in case the class value is missing
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceadams.core.StoppableWithFeedback
- Returns:
- true if stopped
-
-