Package weka.classifiers.meta
Class JepRegressor
- 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.JepRegressor
-
- 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.core.Stoppable
,adams.core.StoppableWithFeedback
,adams.flow.core.FlowContextHandler
,Serializable
,weka.classifiers.Classifier
,ScriptedClassifier
,weka.core.CapabilitiesHandler
,weka.core.OptionHandler
public class JepRegressor extends AbstractSimpleClassifier implements adams.core.StoppableWithFeedback, ScriptedClassifier
Regressor that uses Jep to train and execute a Python-based regressor.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.core.scripting.JepScript
m_ClassifyScript
the classify script.protected adams.core.scripting.JepScript
m_ClassifyScriptActual
the classify script instance to use.protected String
m_ClassifyVarPrefix
the variable prefix to use at prediction time.protected adams.flow.standalone.JepEngine
m_Engine
the engine in use.protected adams.flow.core.Actor
m_FlowContext
the flow context.protected Object
m_Model
the model object.protected boolean
m_Stopped
whether the classifier was stopped.protected adams.core.scripting.JepScript
m_TrainScript
the train script.static String
VAR_PREFIX
-
Constructor Summary
Constructors Constructor Description JepRegressor()
-
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.String
classifyScriptTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.weka.core.Capabilities
getCapabilities()
Returns the Capabilities of this classifier.adams.core.scripting.JepScript
getClassifyScript()
Gets the script to use for classifying Instance objects.adams.flow.core.Actor
getFlowContext()
Returns the flow context.adams.core.scripting.JepScript
getTrainScript()
Gets the train script to use.String
globalInfo()
Returns a string describing the object.void
initPrediction(adams.flow.core.Actor context)
Prepares the classifier for predictions.boolean
isStopped()
Whether the execution has been stopped.static void
main(String[] args)
Runs the classifier from the command-line with the specified options.void
setClassifyScript(adams.core.scripting.JepScript value)
Sets the script to use for classifying Instance objects.void
setFlowContext(adams.flow.core.Actor value)
Sets the flow context.void
setTrainScript(adams.core.scripting.JepScript value)
Sets the train script to use.protected void
setupJepEngine()
Configures the Jep engine if necessary.void
stopExecution()
Stops the execution.String
trainScriptTipText()
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, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
VAR_PREFIX
public static final String VAR_PREFIX
- See Also:
- Constant Field Values
-
m_TrainScript
protected adams.core.scripting.JepScript m_TrainScript
the train script.
-
m_ClassifyScript
protected adams.core.scripting.JepScript m_ClassifyScript
the classify script.
-
m_Stopped
protected boolean m_Stopped
whether the classifier was stopped.
-
m_FlowContext
protected transient adams.flow.core.Actor m_FlowContext
the flow context.
-
m_Engine
protected transient adams.flow.standalone.JepEngine m_Engine
the engine in use.
-
m_Model
protected transient Object m_Model
the model object.
-
m_ClassifyScriptActual
protected transient adams.core.scripting.JepScript m_ClassifyScriptActual
the classify script instance to use.
-
m_ClassifyVarPrefix
protected transient String m_ClassifyVarPrefix
the variable prefix to use at prediction time.
-
-
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
-
setTrainScript
public void setTrainScript(adams.core.scripting.JepScript value)
Sets the train script to use.- Parameters:
value
- the script
-
getTrainScript
public adams.core.scripting.JepScript getTrainScript()
Gets the train script to use.- Returns:
- the script
-
trainScriptTipText
public String trainScriptTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setClassifyScript
public void setClassifyScript(adams.core.scripting.JepScript value)
Sets the script to use for classifying Instance objects.- Parameters:
value
- the script
-
getClassifyScript
public adams.core.scripting.JepScript getClassifyScript()
Gets the script to use for classifying Instance objects.- Returns:
- the script
-
classifyScriptTipText
public String classifyScriptTipText()
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
-
setupJepEngine
protected void setupJepEngine()
Configures the Jep engine if necessary.
-
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
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceadams.core.StoppableWithFeedback
- Returns:
- true if stopped
-
-