Class DJLRegressor

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, adams.flow.core.FlowContextHandler, Serializable, weka.classifiers.Classifier, weka.classifiers.ScriptedClassifier, weka.core.CapabilitiesHandler, weka.core.OptionHandler

    public class DJLRegressor
    extends weka.classifiers.simple.AbstractSimpleClassifier
    implements weka.classifiers.ScriptedClassifier
    Uses Deep Java Library for building a regression model.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_TrainPercentage

        protected int m_TrainPercentage
        the percentage for the network's training set.
      • m_MiniBatchSize

        protected int m_MiniBatchSize
        the batchsize.
      • m_NumEpochs

        protected int m_NumEpochs
        the number of epochs to train.
      • m_ID

        protected IDGenerator m_ID
        the model ID/prefix generator.
      • m_FlowContext

        protected transient adams.flow.core.Actor m_FlowContext
        the flow context.
      • m_Header

        protected weka.core.Instances m_Header
        the header.
      • m_Translator

        protected transient ai.djl.translate.Translator<ai.djl.basicdataset.tabular.ListFeatures,​Float> m_Translator
        the feature translator to use.
      • m_Model

        protected transient ai.djl.Model m_Model
        the model.
      • m_Predictor

        protected transient ai.djl.inference.Predictor<ai.djl.basicdataset.tabular.ListFeatures,​Float> m_Predictor
        the predictor to use.
      • m_DatasetConfig

        protected String m_DatasetConfig
        the dataset config.
    • Constructor Detail

      • DJLRegressor

        public DJLRegressor()
    • 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
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setNetwork

        public void setNetwork​(NetworkGenerator value)
        Sets the network generator to use.
        Parameters:
        value - the generator
      • getNetwork

        public NetworkGenerator getNetwork()
        Gets the network generator to use.
        Returns:
        the generator
      • networkTipText

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

        public void setTrainPercentage​(int value)
        Sets the percentage to use for the internal training set.
        Parameters:
        value - the percentage
      • getTrainPercentage

        public int getTrainPercentage()
        Gets the percentage to use for the internal training set.
        Returns:
        the percentage
      • trainPercentageTipText

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

        public void setMiniBatchSize​(int value)
        Sets the batch size to use.
        Parameters:
        value - the batch size
      • getMiniBatchSize

        public int getMiniBatchSize()
        Gets the batch size to use.
        Returns:
        the batch size
      • miniBatchSizeTipText

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

        public void setNumEpochs​(int value)
        Sets the number of epochs to train for.
        Parameters:
        value - the epochs
      • getNumEpochs

        public int getNumEpochs()
        Gets the number of epochs to train for.
        Returns:
        the epochs
      • numEpochsTipText

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

        public void setID​(IDGenerator value)
        Sets the ID/prefix generator for saving the model.
        Parameters:
        value - the ID/prefix
      • getID

        public IDGenerator getID()
        Gets the ID/prefix generator for saving the model.
        Returns:
        the ID/prefix
      • IDTipText

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

        public void setOutputDir​(OutputDirGenerator value)
        Sets the output directory generator to use.
        Parameters:
        value - the generator
      • getOutputDir

        public OutputDirGenerator getOutputDir()
        Gets the output directory generator to use.
        Returns:
        the generator
      • outputDirTipText

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

        public void setFlowContext​(adams.flow.core.Actor value)
        Sets the flow context.
        Specified by:
        setFlowContext in interface adams.flow.core.FlowContextHandler
        Parameters:
        value - the context
      • getFlowContext

        public adams.flow.core.Actor getFlowContext()
        Returns the flow context.
        Specified by:
        getFlowContext in interface adams.flow.core.FlowContextHandler
        Returns:
        the context, null if not available
      • 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.simple.AbstractSimpleClassifier
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.
        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
      • initPrediction

        public void initPrediction​(adams.flow.core.Actor context)
        Prepares the classifier for predictions.
        Specified by:
        initPrediction in interface weka.classifiers.ScriptedClassifier
        Parameters:
        context - the context to use
      • 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. Note that a classifier MUST implement either this or distributionForInstance().
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.simple.AbstractSimpleClassifier
        Parameters:
        instance - the instance to be classified
        Returns:
        the predicted most likely class for the instance or Utils.missingValue() if no prediction is made
        Throws:
        Exception - if an error occurred during the prediction
      • toString

        public String toString()
        Returns a short description of the setup.
        Overrides:
        toString in class adams.core.option.AbstractOptionHandler
        Returns:
        the description
      • main

        public static void main​(String[] args)
                         throws Exception
        Runs the classifier from the command-line with the specified options.
        Parameters:
        args - the options for the classifier
        Throws:
        Exception - if execution fails