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,weka.classifiers.ScriptedClassifier,weka.core.CapabilitiesHandler,weka.core.OptionHandler
public class JepRegressor extends weka.classifiers.simple.AbstractSimpleClassifier implements adams.core.StoppableWithFeedback, weka.classifiers.ScriptedClassifierRegressor 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 JepScriptm_ClassifyScriptthe classify script.protected JepScriptm_ClassifyScriptActualthe classify script instance to use.protected Stringm_ClassifyVarPrefixthe variable prefix to use at prediction time.protected JepEnginem_Enginethe engine in use.protected adams.flow.core.Actorm_FlowContextthe flow context.protected Objectm_Modelthe model object.protected booleanm_Stoppedwhether the classifier was stopped.protected JepScriptm_TrainScriptthe train script.static StringVAR_PREFIX
-
Constructor Summary
Constructors Constructor Description JepRegressor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(weka.core.Instances data)Generates a classifier.doubleclassifyInstance(weka.core.Instance instance)Classifies the given test instance.StringclassifyScriptTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.weka.core.CapabilitiesgetCapabilities()Returns the Capabilities of this classifier.JepScriptgetClassifyScript()Gets the script to use for classifying Instance objects.adams.flow.core.ActorgetFlowContext()Returns the flow context.JepScriptgetTrainScript()Gets the train script to use.StringglobalInfo()Returns a string describing the object.voidinitPrediction(adams.flow.core.Actor context)Prepares the classifier for predictions.booleanisStopped()Whether the execution has been stopped.static voidmain(String[] args)Runs the classifier from the command-line with the specified options.voidsetClassifyScript(JepScript value)Sets the script to use for classifying Instance objects.voidsetFlowContext(adams.flow.core.Actor value)Sets the flow context.voidsetTrainScript(JepScript value)Sets the train script to use.protected voidsetupJepEngine()Configures the Jep engine if necessary.voidstopExecution()Stops the execution.StringtrainScriptTipText()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 JepScript m_TrainScript
the train script.
-
m_ClassifyScript
protected 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 JepEngine m_Engine
the engine in use.
-
m_Model
protected transient Object m_Model
the model object.
-
m_ClassifyScriptActual
protected transient 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:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin 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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
setTrainScript
public void setTrainScript(JepScript value)
Sets the train script to use.- Parameters:
value- the script
-
getTrainScript
public 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(JepScript value)
Sets the script to use for classifying Instance objects.- Parameters:
value- the script
-
getClassifyScript
public 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:
setFlowContextin interfaceadams.flow.core.FlowContextHandler- Parameters:
value- the context
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context.- Specified by:
getFlowContextin 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:
getCapabilitiesin interfaceweka.core.CapabilitiesHandler- Specified by:
getCapabilitiesin interfaceweka.classifiers.Classifier- Overrides:
getCapabilitiesin classweka.classifiers.simple.AbstractSimpleClassifier- 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 ExceptionGenerates 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:
buildClassifierin 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:
initPredictionin interfaceweka.classifiers.ScriptedClassifier- Parameters:
context- the context to use
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws ExceptionClassifies 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:
classifyInstancein interfaceweka.classifiers.Classifier- Overrides:
classifyInstancein classweka.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
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStoppedin interfaceadams.core.StoppableWithFeedback- Returns:
- true if stopped
-
-