Class FakeClassifier

  • All Implemented Interfaces:
    Serializable, Cloneable, weka.classifiers.Classifier, weka.classifiers.UpdateableClassifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.Randomizable, weka.core.RevisionHandler

    public class FakeClassifier
    extends weka.classifiers.AbstractClassifier
    implements weka.core.Randomizable, weka.classifiers.UpdateableClassifier
    Fake classifier that requires no dataset for training and just outputs random values within the specified bounds.
    Fake build and prediction times can be set as well.

    Valid options are:

     -seed <int>
      The seed value to use.
      (default: 1)
     -build-wait <int>
      The number of msec for the classifier to idle at build time.
      (default: 0)
     -update-wait <int>
      The number of msec for the classifier to idle at incremental build time.
      (default: 0)
     -predict-wait <int>
      The number of msec for the classifier to idle at prediction time.
      (default: 0)
     -predict-min <num>
      The minimum value to use for prediction.
      (default: 0.0)
     -predict-max <num>
      The maximum value to use for prediction.
      (default: 1.0)
     -output-debug-info
      If set, classifier is run in debug mode and
      may output additional info to the console
     -do-not-check-capabilities
      If set, classifier capabilities are not checked before classifier is built
      (use with caution).
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int m_BuildWait
      the build wait time in msec.
      protected double m_PredictMax
      the maximum to use for the predictions.
      protected double m_PredictMin
      the minimum to use for the predictions.
      protected int m_PredictWait
      the predict wait time in msec.
      protected Random m_Random
      for generating the random numbers.
      protected int m_Seed
      the seed.
      protected int m_UpdateWait
      the update wait time in msec.
      • Fields inherited from class weka.classifiers.AbstractClassifier

        BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
    • Constructor Summary

      Constructors 
      Constructor Description
      FakeClassifier()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buildClassifier​(weka.core.Instances data)
      Generates a classifier.
      String buildWaitTipText()
      Returns the tip text for this property.
      double classifyInstance​(weka.core.Instance instance)
      Classifies the given test instance.
      int getBuildWait()
      Returns the time in msec to wait when calling buildClassifier.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this classifier.
      String[] getOptions()
      returns the options of the current setup
      double getPredictMax()
      Returns the maximum value to predict.
      double getPredictMin()
      Returns the minimum value to predict.
      int getPredictWait()
      Returns the time in msec to wait when calling classifyInstance.
      protected Random getRandom()
      Returns the random number generator to use.
      String getRevision()
      Returns the revision string.
      int getSeed()
      Returns the seed value for the random values.
      int getUpdateWait()
      Returns the time in msec to wait when calling updateClassifier.
      String globalInfo()
      Returns a string describing classifier
      Enumeration listOptions()
      Gets an enumeration describing the available options.
      static void main​(String[] args)
      Main method for running this class.
      String predictMaxTipText()
      Returns the tip text for this property.
      String predictMinTipText()
      Returns the tip text for this property.
      String predictWaitTipText()
      Returns the tip text for this property.
      String seedTipText()
      Returns the tip text for this property.
      void setBuildWait​(int value)
      Sets the time in msec to wait when calling buildClassifier.
      void setOptions​(String[] options)
      Parses the options for this object.
      void setPredictMax​(double value)
      Sets the maximum value to predict.
      void setPredictMin​(double value)
      Sets the minimum value to predict.
      void setPredictWait​(int value)
      Sets the time in msec to wait when calling classifyInstance.
      void setSeed​(int value)
      Sets the seed value for the random values.
      void setUpdateWait​(int value)
      Sets the time in msec to wait when calling updateClassifier.
      String toString()
      Returns a string representation of the built model.
      void updateClassifier​(weka.core.Instance instance)
      Does nothing.
      String updateWaitTipText()
      Returns the tip text for this property.
      protected void wait​(int msec)
      Waits for a specified amount of time.
      • Methods inherited from class weka.classifiers.AbstractClassifier

        batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
    • Field Detail

      • m_Seed

        protected int m_Seed
        the seed.
      • m_BuildWait

        protected int m_BuildWait
        the build wait time in msec.
      • m_UpdateWait

        protected int m_UpdateWait
        the update wait time in msec.
      • m_PredictWait

        protected int m_PredictWait
        the predict wait time in msec.
      • m_PredictMin

        protected double m_PredictMin
        the minimum to use for the predictions.
      • m_PredictMax

        protected double m_PredictMax
        the maximum to use for the predictions.
      • m_Random

        protected Random m_Random
        for generating the random numbers.
    • Constructor Detail

      • FakeClassifier

        public FakeClassifier()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing classifier
        Returns:
        a description suitable for displaying in the explorer/experimenter gui
      • listOptions

        public Enumeration listOptions()
        Gets an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.classifiers.AbstractClassifier
        Returns:
        an enumeration of all the available options.
      • getOptions

        public String[] getOptions()
        returns the options of the current setup
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.AbstractClassifier
        Returns:
        the current options
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses the options for this object.
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.AbstractClassifier
        Parameters:
        options - the options to use
        Throws:
        Exception - if setting of options fails
      • setSeed

        public void setSeed​(int value)
        Sets the seed value for the random values.
        Specified by:
        setSeed in interface weka.core.Randomizable
        Parameters:
        value - the seed
      • getSeed

        public int getSeed()
        Returns the seed value for the random values.
        Specified by:
        getSeed in interface weka.core.Randomizable
        Returns:
        the seed
      • seedTipText

        public String seedTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setBuildWait

        public void setBuildWait​(int value)
        Sets the time in msec to wait when calling buildClassifier.
        Parameters:
        value - the time in msec
      • getBuildWait

        public int getBuildWait()
        Returns the time in msec to wait when calling buildClassifier.
        Returns:
        the time in msec
      • buildWaitTipText

        public String buildWaitTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setUpdateWait

        public void setUpdateWait​(int value)
        Sets the time in msec to wait when calling updateClassifier.
        Parameters:
        value - the time in msec
      • getUpdateWait

        public int getUpdateWait()
        Returns the time in msec to wait when calling updateClassifier.
        Returns:
        the time in msec
      • updateWaitTipText

        public String updateWaitTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setPredictWait

        public void setPredictWait​(int value)
        Sets the time in msec to wait when calling classifyInstance.
        Parameters:
        value - the time in msec
      • getPredictWait

        public int getPredictWait()
        Returns the time in msec to wait when calling classifyInstance.
        Returns:
        the time in msec
      • predictWaitTipText

        public String predictWaitTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setPredictMin

        public void setPredictMin​(double value)
        Sets the minimum value to predict.
        Parameters:
        value - the minimum value
      • getPredictMin

        public double getPredictMin()
        Returns the minimum value to predict.
        Returns:
        the minimum value
      • predictMinTipText

        public String predictMinTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setPredictMax

        public void setPredictMax​(double value)
        Sets the maximum value to predict.
        Parameters:
        value - the maximum value
      • getPredictMax

        public double getPredictMax()
        Returns the maximum value to predict.
        Returns:
        the maximum value
      • predictMaxTipText

        public String predictMaxTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this classifier. Maximally permissive capabilities are allowed by default. Derived classifiers should override this method and first disable all capabilities and then enable just those capabilities that make sense for the scheme.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Specified by:
        getCapabilities in interface weka.classifiers.Classifier
        Overrides:
        getCapabilities in class weka.classifiers.AbstractClassifier
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • wait

        protected void wait​(int msec)
        Waits for a specified amount of time.
        Parameters:
        msec - the time in msec to wait
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a classifier.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - set of instances serving as training data
        Throws:
        Exception - if the classifier has not been generated successfully
      • getRandom

        protected Random getRandom()
        Returns the random number generator to use.
        Returns:
        the random number generator
      • updateClassifier

        public void updateClassifier​(weka.core.Instance instance)
                              throws Exception
        Does nothing.
        Specified by:
        updateClassifier in interface weka.classifiers.UpdateableClassifier
        Parameters:
        instance -
        Throws:
        Exception
      • classifyInstance

        public double classifyInstance​(weka.core.Instance instance)
                                throws Exception
        Classifies the given test instance. The instance has to belong to a dataset when it's being classified.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
        Throws:
        Exception - if an error occurred during the prediction
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
        Returns:
        the revision
      • toString

        public String toString()
        Returns a string representation of the built model.
        Overrides:
        toString in class Object
        Returns:
        the model string
      • main

        public static void main​(String[] args)
        Main method for running this class.
        Parameters:
        args - the commandline parameters