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, stringToListpublic static void main(String[] args)
args - general and scheme-specific command line argumentspublic boolean baseModelHasSerializer()
baseModelHasSerializer in interface TSForecasterpublic void saveBaseModel(String filepath) throws Exception
saveBaseModel in interface TSForecasterfilepath - the path of the file to save the base model toExceptionpublic void loadBaseModel(String filepath) throws Exception
loadBaseModel in interface TSForecasterfilepath - the path of the file to load the base model fromExceptionpublic void serializeState(String filepath) throws Exception
serializeState in interface TSForecasterfilepath - the path of the file to save the model state toExceptionpublic void loadSerializedState(String filepath) throws Exception
loadSerializedState in interface TSForecasterfilepath - the path of the file to save the model state fromExceptionpublic boolean usesState()
usesState in interface TSForecasterpublic void clearPreviousState()
clearPreviousState in interface TSForecasterpublic void setPreviousState(List<Object> previousState)
setPreviousState in interface TSForecasterpublic List<Object> getPreviousState()
getPreviousState in interface TSForecasterpublic String getAlgorithmName()
getAlgorithmName in interface TSForecasterpublic TSLagMaker getTSLagMaker()
getTSLagMaker in interface TSLagUserpublic void setTSLagMaker(TSLagMaker lagMaker)
setTSLagMaker in interface TSLagUserlagMaker - the TSLagMaker to use.public Enumeration<weka.core.Option> listOptions()
listOptions in interface weka.core.OptionHandlerpublic String[] getOptions()
getOptions in interface weka.core.OptionHandlerpublic void setOptions(String[] options) throws Exception
setOptions in interface weka.core.OptionHandleroptions - 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 TSForecastersetFieldsToForecast in class AbstractForecasterfieldsToForecast - 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 OverlayForecasterpublic void setOverlayFields(String overlayFields) throws Exception
setOverlayFields in interface OverlayForecasteroverlayFields - a comma-separated list of fieldnamesException - if there is a problem setting the overlay fieldspublic int getCalculateConfIntervalsForForecasts()
getCalculateConfIntervalsForForecasts in interface ConfidenceIntervalForecasterpublic void setCalculateConfIntervalsForForecasts(int steps)
setCalculateConfIntervalsForForecasts in interface ConfidenceIntervalForecastersteps - the number of steps for which to compute confidence intervals
for.public boolean isProducingConfidenceIntervals()
isProducingConfidenceIntervals in interface ConfidenceIntervalForecasterpublic double getConfidenceLevel()
getConfidenceLevel in interface ConfidenceIntervalForecasterpublic void setConfidenceLevel(double confLevel)
setConfidenceLevel in interface ConfidenceIntervalForecasterconfLevel - 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 OverlayForecasterpublic void reset()
reset in interface TSForecasterpublic void buildForecaster(weka.core.Instances insts,
PrintStream... progress)
throws Exception
buildForecaster in interface TSForecasterbuildForecaster in class AbstractForecasterinsts - 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 TSForecasterprimeForecaster in class AbstractForecasterinsts - 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 IncrementallyPrimeableinst - 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 TSForecasterforecast in class AbstractForecasternumSteps - 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 OverlayForecasternumSteps - 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.