public class WekaForecaster extends AbstractForecaster implements TSLagUser, ConfidenceIntervalForecaster, OverlayForecaster, IncrementallyPrimeable, weka.core.OptionHandler, Serializable
Constructor and Description |
---|
WekaForecaster() |
Modifier and Type | Method and Description |
---|---|
void |
addCustomPeriodic(String customPeriodic)
Add a custom date-derived periodic attribute
|
boolean |
baseModelHasSerializer()
Check whether the base learner requires special serialization
|
void |
buildForecaster(weka.core.Instances insts,
PrintStream... progress)
Builds a new forecasting model using the supplied training data.
|
void |
clearCustomPeriodics()
clear the list of custom date-derived periodic attributes
|
void |
clearPreviousState()
Reset model state.
|
List<List<weka.classifiers.evaluation.NumericPrediction>> |
forecast(int numSteps,
weka.core.Instances overlay,
PrintStream... progress)
Produce a forecast for the target field(s).
|
List<List<weka.classifiers.evaluation.NumericPrediction>> |
forecast(int numSteps,
PrintStream... progress)
Produce a forecast for the target field(s).
|
String |
getAlgorithmName()
Provides a short name that describes the underlying algorithm in some way.
|
weka.classifiers.Classifier |
getBaseForecaster()
Get the base Weka regression scheme being used to make forecasts
|
int |
getCalculateConfIntervalsForForecasts()
Return the number of steps for which confidence intervals will be computed.
|
double |
getConfidenceLevel()
Get the confidence level in use for computing confidence intervals.
|
String[] |
getOptions()
Gets the current settings of this Forecaster.
|
String |
getOverlayFields()
Get a comma-separated list of fields that considered to be overlay fields
|
List<Object> |
getPreviousState()
Get the last set state of the model.
|
TSLagMaker |
getTSLagMaker()
Get the TSLagMaker that we are using.
|
boolean |
isProducingConfidenceIntervals()
Returns true if this forecaster is computing confidence limits for some or
all of its future forecasts (i.e.
|
boolean |
isUsingOverlayData()
Returns true if overlay data has been used to train this forecaster, and
thus is expected to be supplied for future time steps when making a
forecast.
|
Enumeration<weka.core.Option> |
listOptions()
Returns an enumeration describing the available options.
|
void |
loadBaseModel(String filepath)
Load serialized classifier
|
void |
loadSerializedState(String filepath)
Load serialized model state
|
static void |
main(String[] args)
Main method for running this class from the command line
|
void |
primeForecaster(weka.core.Instances insts)
Supply the (potentially) trained model with enough historical data, up to
and including the current time point, in order to produce a forecast.
|
void |
primeForecasterIncremental(weka.core.Instance inst)
Update the priming information incrementally, i.e.
|
void |
reset()
Reset the forecaster.
|
void |
saveBaseModel(String filepath)
Save underlying classifier
|
void |
serializeState(String filepath)
Serialize model state
|
void |
setBaseForecaster(weka.classifiers.Classifier f)
Set the base Weka regression scheme to use.
|
void |
setCalculateConfIntervalsForForecasts(int steps)
Set the number of steps for which to compute confidence intervals for.
|
void |
setConfidenceLevel(double confLevel)
Set the confidence level for confidence intervals.
|
void |
setFieldsToForecast(String fieldsToForecast)
Set the names of the fields/attributes in the data to forecast.
|
void |
setOptions(String[] options)
Set the options for the forecaster
|
void |
setOverlayFields(String overlayFields)
Set the fields to consider as overlay fields
|
void |
setPreviousState(List<Object> previousState)
Load state into model.
|
void |
setTSLagMaker(TSLagMaker lagMaker)
Set the TSLagMaker to use.
|
String |
toString() |
boolean |
usesState()
Check whether the base learner requires operations regarding state
|
getFieldsToForecast, makeCopy, postExecution, preExecution, run, runForecaster, stringToList
public static void main(String[] args)
args
- general and scheme-specific command line argumentspublic boolean baseModelHasSerializer()
baseModelHasSerializer
in interface TSForecaster
public void saveBaseModel(String filepath) throws Exception
saveBaseModel
in interface TSForecaster
filepath
- the path of the file to save the base model toException
public void loadBaseModel(String filepath) throws Exception
loadBaseModel
in interface TSForecaster
filepath
- the path of the file to load the base model fromException
public void serializeState(String filepath) throws Exception
serializeState
in interface TSForecaster
filepath
- the path of the file to save the model state toException
public void loadSerializedState(String filepath) throws Exception
loadSerializedState
in interface TSForecaster
filepath
- the path of the file to save the model state fromException
public boolean usesState()
usesState
in interface TSForecaster
public void clearPreviousState()
clearPreviousState
in interface TSForecaster
public void setPreviousState(List<Object> previousState)
setPreviousState
in interface TSForecaster
public List<Object> getPreviousState()
getPreviousState
in interface TSForecaster
public String getAlgorithmName()
getAlgorithmName
in interface TSForecaster
public TSLagMaker getTSLagMaker()
getTSLagMaker
in interface TSLagUser
public void setTSLagMaker(TSLagMaker lagMaker)
setTSLagMaker
in interface TSLagUser
lagMaker
- the TSLagMaker to use.public Enumeration<weka.core.Option> listOptions()
listOptions
in interface weka.core.OptionHandler
public String[] getOptions()
getOptions
in interface weka.core.OptionHandler
public void setOptions(String[] options) throws Exception
setOptions
in interface weka.core.OptionHandler
options
- an array of optionsException
- if unknown options are suppliedpublic void addCustomPeriodic(String customPeriodic)
customPeriodic
- the string definition of the custom date derived
periodic attribute to addpublic void clearCustomPeriodics()
public void setFieldsToForecast(String fieldsToForecast) throws Exception
setFieldsToForecast
in interface TSForecaster
setFieldsToForecast
in class AbstractForecaster
fieldsToForecast
- a list of names of fields to forecastException
- if a field(s) can't be found, or if multiple fields are
specified and this forecaster can't predict multiple fields.public String getOverlayFields()
getOverlayFields
in interface OverlayForecaster
public void setOverlayFields(String overlayFields) throws Exception
setOverlayFields
in interface OverlayForecaster
overlayFields
- a comma-separated list of fieldnamesException
- if there is a problem setting the overlay fieldspublic int getCalculateConfIntervalsForForecasts()
getCalculateConfIntervalsForForecasts
in interface ConfidenceIntervalForecaster
public void setCalculateConfIntervalsForForecasts(int steps)
setCalculateConfIntervalsForForecasts
in interface ConfidenceIntervalForecaster
steps
- the number of steps for which to compute confidence intervals
for.public boolean isProducingConfidenceIntervals()
isProducingConfidenceIntervals
in interface ConfidenceIntervalForecaster
public double getConfidenceLevel()
getConfidenceLevel
in interface ConfidenceIntervalForecaster
public void setConfidenceLevel(double confLevel)
setConfidenceLevel
in interface ConfidenceIntervalForecaster
confLevel
- the confidence level to use.public weka.classifiers.Classifier getBaseForecaster()
public void setBaseForecaster(weka.classifiers.Classifier f)
f
- the base Weka regression scheme to use for forecasting.public boolean isUsingOverlayData()
isUsingOverlayData
in interface OverlayForecaster
public void reset()
reset
in interface TSForecaster
public void buildForecaster(weka.core.Instances insts, PrintStream... progress) throws Exception
buildForecaster
in interface TSForecaster
buildForecaster
in class AbstractForecaster
insts
- the training instances.progress
- an optional varargs parameter supplying progress objects to
report/log toException
- if the model can't be constructed for some reason.public void primeForecaster(weka.core.Instances insts) throws Exception
primeForecaster
in interface TSForecaster
primeForecaster
in class AbstractForecaster
insts
- the instances to prime the model withException
- if the model can't be primed for some reason.public void primeForecasterIncremental(weka.core.Instance inst) throws Exception
primeForecasterIncremental
in interface IncrementallyPrimeable
inst
- the instance to prime with.Exception
- if something goes wrong.public List<List<weka.classifiers.evaluation.NumericPrediction>> forecast(int numSteps, PrintStream... progress) throws Exception
forecast
in interface TSForecaster
forecast
in class AbstractForecaster
numSteps
- number of forecasted values to produce for each target.
E.g. a value of 5 would produce a prediction for t+1, t+2, ...,
t+5. if no overlay data has been used during training)progress
- an optional varargs parameter supplying progress objects to
report/log toException
- if the forecast can't be produced for some reason.public List<List<weka.classifiers.evaluation.NumericPrediction>> forecast(int numSteps, weka.core.Instances overlay, PrintStream... progress) throws Exception
forecast
in interface OverlayForecaster
numSteps
- number of forecasted values to produce for each target.
E.g. a value of 5 would produce a prediction for t+1, t+2, ...,
t+5.overlay
- optional overlay data for the period to be forecasted (may
be null if no overlay data has been used during training)progress
- an optional varargs parameter supplying progress objects to
report/log toException
- if the forecast can't be produced for some reason.Copyright © 2019 University of Waikato, Hamilton, NZ. All Rights Reserved.