Class AbstractCommunicationProcessor

  • 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
    Direct Known Subclasses:
    FusionJsonCommunicationProcessor, NullCommunicationProcessor, SimpleJsonCommunicationProcessor

    public abstract class AbstractCommunicationProcessor
    extends adams.core.option.AbstractOptionHandler
    Ancestor for classes processing the communication to/fro Pyro proxy models.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractCommunicationProcessor

        public AbstractCommunicationProcessor()
    • Method Detail

      • checkInitialize

        protected String checkInitialize​(weka.core.Instances data)
        Hook method for performing checks before initializing.
        Parameters:
        data - the Instances to check
        Returns:
        null if successful, otherwise the error message
      • doInitialize

        protected abstract void doInitialize​(PyroProxy owner,
                                             weka.core.Instances data)
                                      throws Exception
        Performs the initialization.
        Parameters:
        owner - the owning classifier
        data - the training data
        Throws:
        Exception - if initialization fails
      • initialize

        public void initialize​(PyroProxy owner,
                               weka.core.Instances data)
                        throws Exception
        Converts the instance into a different format.
        Parameters:
        owner - the owning classifier
        data - the training data
        Throws:
        Exception - if check or initialization fails
      • checkDataset

        protected String checkDataset​(weka.core.Instances data)
        Hook method for performing checks before converting a dataset.
        Parameters:
        data - the dataset to check
        Returns:
        null if successful, otherwise the error message
      • doConvertDataset

        protected abstract Object doConvertDataset​(PyroProxy owner,
                                                   weka.core.Instances data)
                                            throws Exception
        Performs the dataset conversion.
        Parameters:
        owner - the owning classifier
        data - the dataset to convert
        Returns:
        the converted dataset
        Throws:
        Exception - if build fails
      • convertDataset

        public Object convertDataset​(PyroProxy owner,
                                     weka.core.Instances data)
                              throws Exception
        Performs the dataset conversion.
        Parameters:
        owner - the owning classifier
        data - the dataset to convert
        Returns:
        the converted dataset
        Throws:
        Exception - if check or build fails
      • checkInstance

        protected String checkInstance​(weka.core.Instance inst)
        Hook method for performing checks before converting the Instance.
        Parameters:
        inst - the Instance to check
        Returns:
        null if successful, otherwise the error message
      • doConvertInstance

        protected abstract Object doConvertInstance​(PyroProxy owner,
                                                    weka.core.Instance inst)
                                             throws Exception
        Converts the instance into a different format.
        Parameters:
        owner - the owning classifier
        inst - the instance to convert
        Returns:
        the generated data structure
        Throws:
        Exception - if conversion fails
      • convertInstance

        public Object convertInstance​(PyroProxy owner,
                                      weka.core.Instance inst)
                               throws Exception
        Converts the instance into a different format.
        Parameters:
        owner - the owning classifier
        inst - the instance to convert
        Returns:
        the generated data structure
        Throws:
        Exception - if check or conversion fails
      • checkPrediction

        protected String checkPrediction​(Object prediction)
        Hook method for performing checks before parsing the prediction.
        Parameters:
        prediction - the prediction to check
        Returns:
        null if successful, otherwise the error message
      • doParsePrediction

        protected abstract double[] doParsePrediction​(PyroProxy owner,
                                                      Object prediction)
                                               throws Exception
        Parses the prediction.
        Parameters:
        owner - the owning classifier
        prediction - the prediction to parse
        Returns:
        the class distribution
        Throws:
        Exception - if conversion fails
      • parsePrediction

        public double[] parsePrediction​(PyroProxy owner,
                                        Object prediction)
                                 throws Exception
        Parses the prediction.
        Parameters:
        owner - the owning classifier
        prediction - the prediction to parse
        Returns:
        the class distribution
        Throws:
        Exception - if check or conversion fails
      • supportsBatchPredictions

        public abstract boolean supportsBatchPredictions()
        Returns whether batch predictions are supported.
        Returns:
        true if supported
      • checkPredictions

        protected String checkPredictions​(Object predictions)
        Hook method for performing checks before parsing the predictions.
        Parameters:
        predictions - the prediction to check
        Returns:
        null if successful, otherwise the error message
      • doParsePredictions

        protected abstract double[][] doParsePredictions​(PyroProxy owner,
                                                         Object predictions)
                                                  throws Exception
        Parses the predictions.
        Parameters:
        owner - the owning classifier
        predictions - the predictions to parse
        Returns:
        the class distribution
        Throws:
        Exception - if conversion fails
      • parsePredictions

        public double[][] parsePredictions​(PyroProxy owner,
                                           Object predictions)
                                    throws Exception
        Parses the predictions.
        Parameters:
        owner - the owning classifier
        predictions - the predictions to parse
        Returns:
        the class distribution
        Throws:
        Exception - if check or conversion fails