Package adams.flow.source
Class WekaForecasting
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,ModelFileHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,DynamicInitializer
,ErrorHandler
,OutputProducer
,Serializable
,Comparable
public class WekaForecasting extends AbstractSimpleSource implements ModelFileHandler, DynamicInitializer
Uses a serialized model to perform predictions on the data being passed through.
The model can also be obtained from a callable actor, if the model file is pointing to a directory.
Input/output:
- generates:
adams.flow.container.WekaForecastContainer
Container information:
- adams.flow.container.WekaForecastContainer: Model, Forecasts
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: WekaForecasting
-annotation <adams.core.base.BaseText> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors. default: false
-model <adams.core.io.PlaceholderFile> (property: modelFile) The model file to load (when not pointing to a directory). default: ${CWD}
-model-actor <adams.flow.core.CallableActorReference> (property: modelActor) The callable actor to use for obtaining the model in case serialized model file points to a directory; can be a adams.flow.container.WekaModelContainer or a weka.classifiers.timeseries.AbstractForecaster. default:
-on-the-fly <boolean> (property: onTheFly) If set to true, the model file is not required to be present at set up time (eg if built on the fly), only at execution time. default: false
-num-steps <int> (property: numSteps) The number of steps to forecast. default: 1 minimum: 1
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.classifiers.timeseries.AbstractForecaster
m_Model
the model that was loaded from the model file.protected CallableActorReference
m_ModelActor
the callable actor to get the model from.protected PlaceholderFile
m_ModelFile
the serialized model to load.protected int
m_NumSteps
the number of steps to forecast.protected boolean
m_OnTheFly
whether the model gets built on the fly and might not be present at the start.-
Fields inherited from class adams.flow.source.AbstractSimpleSource
m_OutputToken
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description WekaForecasting()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.Class[]
generates()
Returns the class of objects that it generates.CallableActorReference
getModelActor()
Returns the callable actor to obtain the model from if model file is pointing to a directory.PlaceholderFile
getModelFile()
Returns the file to load the model from.int
getNumSteps()
Returns the number of steps to forecast.boolean
getOnTheFly()
Returns whether the model file gets built on the fly and might not be present at start up time.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.String
modelActorTipText()
Returns the tip text for this property.String
modelFileTipText()
Returns the tip text for this property.String
numStepsTipText()
Returns the tip text for this property.String
onTheFlyTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setModelActor(CallableActorReference value)
Sets the callable actor to obtain the model from if model file is pointing to a directory.void
setModelFile(PlaceholderFile value)
Sets the file to load the model from.void
setNumSteps(int value)
Sets the number of steps to forecast.void
setOnTheFly(boolean value)
Sets whether the model file gets built on the fly and might not be present at start up time.String
setUp()
Initializes the item for flow execution.protected String
setUpModel()
Loads the model from the model file.-
Methods inherited from class adams.flow.source.AbstractSimpleSource
hasPendingOutput, initialize, output
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged, wrapUp
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged, wrapUp
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
m_ModelFile
protected PlaceholderFile m_ModelFile
the serialized model to load.
-
m_ModelActor
protected CallableActorReference m_ModelActor
the callable actor to get the model from.
-
m_Model
protected weka.classifiers.timeseries.AbstractForecaster m_Model
the model that was loaded from the model file.
-
m_OnTheFly
protected boolean m_OnTheFly
whether the model gets built on the fly and might not be present at the start.
-
m_NumSteps
protected int m_NumSteps
the number of steps to forecast.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- 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 interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractSimpleSource
-
setModelFile
public void setModelFile(PlaceholderFile value)
Sets the file to load the model from.- Specified by:
setModelFile
in interfaceModelFileHandler
- Parameters:
value
- the model file
-
getModelFile
public PlaceholderFile getModelFile()
Returns the file to load the model from.- Specified by:
getModelFile
in interfaceModelFileHandler
- Returns:
- the model file
-
modelFileTipText
public String modelFileTipText()
Returns the tip text for this property.- Specified by:
modelFileTipText
in interfaceModelFileHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setModelActor
public void setModelActor(CallableActorReference value)
Sets the callable actor to obtain the model from if model file is pointing to a directory.- Parameters:
value
- the actor reference
-
getModelActor
public CallableActorReference getModelActor()
Returns the callable actor to obtain the model from if model file is pointing to a directory.- Returns:
- the actor reference
-
modelActorTipText
public String modelActorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOnTheFly
public void setOnTheFly(boolean value)
Sets whether the model file gets built on the fly and might not be present at start up time.- Specified by:
setOnTheFly
in interfaceDynamicInitializer
- Parameters:
value
- if true then the model does not have to be present at start up time
-
getOnTheFly
public boolean getOnTheFly()
Returns whether the model file gets built on the fly and might not be present at start up time.- Specified by:
getOnTheFly
in interfaceDynamicInitializer
- Returns:
- true if the model is not necessarily present at start up time
-
onTheFlyTipText
public String onTheFlyTipText()
Returns the tip text for this property.- Specified by:
onTheFlyTipText
in interfaceDynamicInitializer
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumSteps
public void setNumSteps(int value)
Sets the number of steps to forecast.- Parameters:
value
- the steps
-
getNumSteps
public int getNumSteps()
Returns the number of steps to forecast.- Returns:
- the steps
-
numStepsTipText
public String numStepsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generates
in interfaceOutputProducer
- Returns:
- adams.flow.container.WekaForecastContainer.class
-
setUpModel
protected String setUpModel()
Loads the model from the model file.- Returns:
- null if everything worked, otherwise an error message
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecute
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
-