Package weka.classifiers.meta
Class DJLRegressor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- weka.core.AbstractSimpleOptionHandler
-
- weka.classifiers.simple.AbstractSimpleClassifier
-
- weka.classifiers.meta.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
,ScriptedClassifier
,weka.core.CapabilitiesHandler
,weka.core.OptionHandler
public class DJLRegressor extends AbstractSimpleClassifier implements ScriptedClassifier
Uses Deep Java Library for building a regression model.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected InstancesDataset
m_Dataset
the DJL dataset.protected String
m_DatasetConfig
the dataset config.protected adams.flow.core.Actor
m_FlowContext
the flow context.protected weka.core.Instances
m_Header
the header.protected adams.data.djl.idgenerator.IDGenerator
m_ID
the model ID/prefix generator.protected int
m_MiniBatchSize
the batchsize.protected ai.djl.Model
m_Model
the model.protected adams.data.djl.networkgenerator.NetworkGenerator
m_Network
the network generator to use.protected int
m_NumEpochs
the number of epochs to train.protected adams.data.djl.outputdirgenerator.OutputDirGenerator
m_OutputDir
the output dir generator.protected ai.djl.inference.Predictor<ai.djl.basicdataset.tabular.ListFeatures,Float>
m_Predictor
the predictor to use.protected int
m_TrainPercentage
the percentage for the network's training set.protected ai.djl.translate.Translator<ai.djl.basicdataset.tabular.ListFeatures,Float>
m_Translator
the feature translator to use.
-
Constructor Summary
Constructors Constructor Description DJLRegressor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Generates a classifier.double
classifyInstance(weka.core.Instance instance)
Classifies the given test instance.void
defineOptions()
Adds options to the internal list of options.weka.core.Capabilities
getCapabilities()
Returns the Capabilities of this classifier.adams.flow.core.Actor
getFlowContext()
Returns the flow context.adams.data.djl.idgenerator.IDGenerator
getID()
Gets the ID/prefix generator for saving the model.int
getMiniBatchSize()
Gets the batch size to use.adams.data.djl.networkgenerator.NetworkGenerator
getNetwork()
Gets the network generator to use.int
getNumEpochs()
Gets the number of epochs to train for.adams.data.djl.outputdirgenerator.OutputDirGenerator
getOutputDir()
Gets the output directory generator to use.int
getTrainPercentage()
Gets the percentage to use for the internal training set.String
globalInfo()
Returns a string describing the object.String
IDTipText()
Returns the tip text for this property.void
initPrediction(adams.flow.core.Actor context)
Prepares the classifier for predictions.static void
main(String[] args)
Runs the classifier from the command-line with the specified options.String
miniBatchSizeTipText()
Returns the tip text for this property.String
networkTipText()
Returns the tip text for this property.String
numEpochsTipText()
Returns the tip text for this property.String
outputDirTipText()
Returns the tip text for this property.void
setFlowContext(adams.flow.core.Actor value)
Sets the flow context.void
setID(adams.data.djl.idgenerator.IDGenerator value)
Sets the ID/prefix generator for saving the model.void
setMiniBatchSize(int value)
Sets the batch size to use.void
setNetwork(adams.data.djl.networkgenerator.NetworkGenerator value)
Sets the network generator to use.void
setNumEpochs(int value)
Sets the number of epochs to train for.void
setOutputDir(adams.data.djl.outputdirgenerator.OutputDirGenerator value)
Sets the output directory generator to use.void
setTrainPercentage(int value)
Sets the percentage to use for the internal training set.String
toString()
Returns a short description of the setup.String
trainPercentageTipText()
Returns the tip text for this property.-
Methods inherited from class weka.classifiers.simple.AbstractSimpleClassifier
distributionForInstance, runClassifier
-
Methods inherited from class weka.core.AbstractSimpleOptionHandler
getOptions, listOptions, setOptions
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Network
protected adams.data.djl.networkgenerator.NetworkGenerator m_Network
the network generator to use.
-
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 adams.data.djl.idgenerator.IDGenerator m_ID
the model ID/prefix generator.
-
m_OutputDir
protected adams.data.djl.outputdirgenerator.OutputDirGenerator m_OutputDir
the output dir 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_Dataset
protected transient InstancesDataset m_Dataset
the DJL dataset.
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.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 interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
setNetwork
public void setNetwork(adams.data.djl.networkgenerator.NetworkGenerator value)
Sets the network generator to use.- Parameters:
value
- the generator
-
getNetwork
public adams.data.djl.networkgenerator.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(adams.data.djl.idgenerator.IDGenerator value)
Sets the ID/prefix generator for saving the model.- Parameters:
value
- the ID/prefix
-
getID
public adams.data.djl.idgenerator.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(adams.data.djl.outputdirgenerator.OutputDirGenerator value)
Sets the output directory generator to use.- Parameters:
value
- the generator
-
getOutputDir
public adams.data.djl.outputdirgenerator.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 interfaceadams.flow.core.FlowContextHandler
- Parameters:
value
- the context
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context.- Specified by:
getFlowContext
in interfaceadams.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 interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classAbstractSimpleClassifier
- 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 interfaceweka.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 interfaceScriptedClassifier
- 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 interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classAbstractSimpleClassifier
- 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 classadams.core.option.AbstractOptionHandler
- Returns:
- the description
-
-