Class Simple

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable

    public class Simple
    extends AbstractDataPreparation
    Simple preparation scheme, using JSON with the actual data in CSV format.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Constructor Summary

      Constructors 
      Constructor Description
      Simple()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addDatasetInfo​(com.google.gson.JsonObject json, weka.core.Instances data)
      Information about the dataset to the JSON object.
      protected com.google.gson.JsonElement fromBytes​(byte[] data)
      Turns the bytes back into a JSON object.
      String globalInfo()
      Returns a string describing the object.
      double parseClassify​(byte[] data)
      Parses the data received from the process, to be returned by the Classifier.classifyInstance(Instance) method.
      double[] parseDistribution​(byte[] data, int numClasses)
      Parses the data received from the process, to be returned by the Classifier.distributionForInstance(Instance) method.
      String parseTrain​(byte[] data)
      Parses the data received from the process from the training process.
      byte[] prepareClassify​(weka.core.Instance inst, SocketFacade facade)
      Prepares the instance for the Classifier.classifyInstance(Instance) method.
      byte[] prepareDistribution​(weka.core.Instance inst, SocketFacade facade)
      Prepares the instance for the Classifier.distributionForInstance(Instance) method.
      byte[] prepareTrain​(weka.core.Instances data, SocketFacade facade)
      Prepares the data for training.
      protected byte[] toBytes​(com.google.gson.JsonObject json)
      Turns the JSON object into bytes.
      protected String toCSV​(weka.core.Instance inst)
      Turns the instance into CSV.
      protected String toCSV​(weka.core.Instances data)
      Turns the instances into CSV.
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Constructor Detail

      • Simple

        public Simple()
    • 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
      • toBytes

        protected byte[] toBytes​(com.google.gson.JsonObject json)
        Turns the JSON object into bytes.
        Parameters:
        json - the object to convert
        Returns:
        the bytes
      • toCSV

        protected String toCSV​(weka.core.Instances data)
        Turns the instances into CSV.
        Parameters:
        data - the instances to convert
        Returns:
        the CSV string
      • toCSV

        protected String toCSV​(weka.core.Instance inst)
        Turns the instance into CSV.
        Parameters:
        inst - the instance to convert
        Returns:
        the CSV string
      • addDatasetInfo

        protected void addDatasetInfo​(com.google.gson.JsonObject json,
                                      weka.core.Instances data)
        Information about the dataset to the JSON object.
        Parameters:
        json - the json object to add to
        data - the dataset structure
      • prepareTrain

        public byte[] prepareTrain​(weka.core.Instances data,
                                   SocketFacade facade)
        Prepares the data for training.
        Specified by:
        prepareTrain in class AbstractDataPreparation
        Parameters:
        data - the data to use
        facade - the classifier using the data preparation
        Returns:
        the prepared data
      • prepareClassify

        public byte[] prepareClassify​(weka.core.Instance inst,
                                      SocketFacade facade)
        Prepares the instance for the Classifier.classifyInstance(Instance) method.
        Specified by:
        prepareClassify in class AbstractDataPreparation
        Parameters:
        inst - the data to use
        facade - the classifier using the data preparation
        Returns:
        the prepared data
      • prepareDistribution

        public byte[] prepareDistribution​(weka.core.Instance inst,
                                          SocketFacade facade)
        Prepares the instance for the Classifier.distributionForInstance(Instance) method.
        Specified by:
        prepareDistribution in class AbstractDataPreparation
        Parameters:
        inst - the data to use
        facade - the classifier using the data preparation
        Returns:
        the prepared data
      • fromBytes

        protected com.google.gson.JsonElement fromBytes​(byte[] data)
        Turns the bytes back into a JSON object.
        Parameters:
        data - the data
        Returns:
        the generate JSON object
      • parseTrain

        public String parseTrain​(byte[] data)
        Parses the data received from the process from the training process.
        Specified by:
        parseTrain in class AbstractDataPreparation
        Parameters:
        data - the data to parse
        Returns:
        null if successful, otherwise error message
      • parseClassify

        public double parseClassify​(byte[] data)
        Parses the data received from the process, to be returned by the Classifier.classifyInstance(Instance) method.
        Specified by:
        parseClassify in class AbstractDataPreparation
        Parameters:
        data - the data to parse
        Returns:
        the classification
      • parseDistribution

        public double[] parseDistribution​(byte[] data,
                                          int numClasses)
        Parses the data received from the process, to be returned by the Classifier.distributionForInstance(Instance) method.
        Specified by:
        parseDistribution in class AbstractDataPreparation
        Parameters:
        data - the data to parse
        numClasses - the number of classes
        Returns:
        the class distribution