Class CrossValidatedPrediction

  • 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, Evaluator, WekaClassifierBasedEvaluator, Serializable, Comparable

    public class CrossValidatedPrediction
    extends AbstractNearestNeighborBasedEvaluator
    implements adams.core.Randomizable, WekaClassifierBasedEvaluator
    Evaluator that (kind of) cross-validates the specified classifier on the neighborhood determined for the instance under evaluation.
    A classifier is built on each of the training sets that is generated for the cross-validation. Each classifier makes a prediction for the Instance that is currently being evaluated, recording the prediction. From the recorded predictions the statistic is computed and output as evaluation value.

    Statistics:
    - STDEV
    standard deviation
    - STDEV_NORMALIZED
    standard deviation of normalized predictions
    predNew = (pred - minClass) / (maxClass - minClass)
    minClass/maxClass the min/max of the class value in the training set
    - RANGE
    outputs range (max - min) of predictions


    -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 <STDEV|STDEV_NORMALIZED|RANGE> (property: statistic)
        The statistic to use as evaluation output.
        default: STDEV
     
    Version:
    $Revision: 2242 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • 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_ClassStats

        protected weka.core.AttributeStats m_ClassStats
        the attribute statistics of the class attribute.
    • Constructor Detail

      • CrossValidatedPrediction

        public CrossValidatedPrediction()
    • 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
      • 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 interface WekaClassifierBasedEvaluator
        Parameters:
        value - the classifier
      • classifierTipText

        public String classifierTipText()
        Returns the tip text for this property.
        Specified by:
        classifierTipText in interface WekaClassifierBasedEvaluator
        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 interface adams.core.Randomizable
        Parameters:
        value - the seed
      • getSeed

        public long getSeed()
        Returns the seed value for cross-validation.
        Specified by:
        getSeed in interface adams.core.Randomizable
        Returns:
        the seed
      • seedTipText

        public String seedTipText()
        Returns the tip text for this property.
        Specified by:
        seedTipText in interface adams.core.Randomizable
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • 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 interface adams.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 interface adams.core.SerializableObject
        Parameters:
        value - the deserialized objects
      • performBuild

        protected boolean performBuild​(weka.core.Instances data)
        Builds the evaluator.
        Specified by:
        performBuild in class AbstractEvaluator
        Parameters:
        data - the instance to check
        Returns:
        always true