net.sourceforge.openforecast.models
Class AbstractForecastingModel

java.lang.Object
  extended by net.sourceforge.openforecast.models.AbstractForecastingModel
All Implemented Interfaces:
ForecastingModel
Direct Known Subclasses:
AbstractTimeBasedModel, MultipleLinearRegressionModel, PolynomialRegressionModel, RegressionModel

public abstract class AbstractForecastingModel
extends Object
implements ForecastingModel

This class implements a variety of methods that are common across all forecasting models. In particular, the calculation of the accuracy indicators can be generalized, and is therefore implemented in the method, calculateAccuracyIndicators.

Since:
0.3
Author:
Steven R. Gould
See Also:
calculateAccuracyIndicators(net.sourceforge.openforecast.DataSet)

Field Summary
protected  net.sourceforge.openforecast.models.AccuracyIndicators accuracyIndicators
          The accuracy indicators, or measures of accuracy, obtained by applying this forecasting model to the initial data set.
protected  boolean initialized
          Remembers whether this model has been properly initialized.
 
Constructor Summary
protected AbstractForecastingModel()
          Default constructor.
 
Method Summary
protected  void calculateAccuracyIndicators(DataSet dataSet)
          A helper method to calculate the various accuracy indicators when applying the given DataSet to the current forecasting model.
 DataSet forecast(DataSet dataSet)
          Using the current model parameters (initialized in init), apply the forecast model to the given data set.
 double getAIC()
          Returns the Akaike Information Criteria obtained from applying the current forecasting model to the initial data set to try and predict each data point.
 double getBias()
          Returns the bias - the arithmetic mean of the errors - obtained from applying the current forecasting model to the initial data set to try and predict each data point.
 double getMAD()
          Returns the mean absolute deviation obtained from applying the current forecasting model to the initial data set to try and predict each data point.
 double getMAPE()
          Returns the mean absolute percentage error obtained from applying the current forecasting model to the initial data set to try and predict each data point.
 double getMSE()
          Returns the mean square of the errors (MSE) obtained from applying the current forecasting model to the initial data set to try and predict each data point.
 double getSAE()
          Returns the Sum of Absolute Errors (SAE) obtained by applying the current forecasting model to the initial data set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.openforecast.ForecastingModel
forecast, getForecastType, getNumberOfPredictors, init, toString
 

Field Detail

accuracyIndicators

protected net.sourceforge.openforecast.models.AccuracyIndicators accuracyIndicators
The accuracy indicators, or measures of accuracy, obtained by applying this forecasting model to the initial data set. Initialized following a call to init.


initialized

protected boolean initialized
Remembers whether this model has been properly initialized.

Constructor Detail

AbstractForecastingModel

protected AbstractForecastingModel()
Default constructor.

Method Detail

getAIC

public double getAIC()
Returns the Akaike Information Criteria obtained from applying the current forecasting model to the initial data set to try and predict each data point. The result is an indication of the accuracy of the model when applied to your initial data set - the smaller the Akaike Information Criteria (AIC), the more accurate the model.

Specified by:
getAIC in interface ForecastingModel
Returns:
the Akaike Information Criteria (AIC) when the current model was applied to the initial data set.
Throws:
ModelNotInitializedException - if getAIC is called before the model has been initialized with a call to init.
Since:
0.5

getBias

public double getBias()
Returns the bias - the arithmetic mean of the errors - obtained from applying the current forecasting model to the initial data set to try and predict each data point. The result is an indication of the accuracy of the model when applied to your initial data set - the smaller the bias, the more accurate the model.

Specified by:
getBias in interface ForecastingModel
Returns:
the bias - mean of the errors - when the current model was applied to the initial data set.
Throws:
ModelNotInitializedException - if getBias is called before the model has been initialized with a call to init.

getMAD

public double getMAD()
Returns the mean absolute deviation obtained from applying the current forecasting model to the initial data set to try and predict each data point. The result is an indication of the accuracy of the model when applied to your initial data set - the smaller the Mean Absolute Deviation (MAD), the more accurate the model.

Specified by:
getMAD in interface ForecastingModel
Returns:
the mean absolute deviation (MAD) when the current model was applied to the initial data set.
Throws:
ModelNotInitializedException - if getMAD is called before the model has been initialized with a call to init.

getMAPE

public double getMAPE()
Returns the mean absolute percentage error obtained from applying the current forecasting model to the initial data set to try and predict each data point. The result is an indication of the accuracy of the model when applied to the initial data set - the smaller the Mean Absolute Percentage Error (MAPE), the more accurate the model.

Specified by:
getMAPE in interface ForecastingModel
Returns:
the mean absolute percentage error (MAPE) when the current model was applied to the initial data set.
Throws:
ModelNotInitializedException - if getMAPE is called before the model has been initialized with a call to init.

getMSE

public double getMSE()
Returns the mean square of the errors (MSE) obtained from applying the current forecasting model to the initial data set to try and predict each data point. The result is an indication of the accuracy of the model when applied to your initial data set - the smaller the Mean Square of the Errors, the more accurate the model.

Specified by:
getMSE in interface ForecastingModel
Returns:
the mean square of the errors (MSE) when the current model was applied to the initial data set.
Throws:
ModelNotInitializedException - if getMSE is called before the model has been initialized with a call to init.

getSAE

public double getSAE()
Returns the Sum of Absolute Errors (SAE) obtained by applying the current forecasting model to the initial data set. Initialized following a call to init.

Specified by:
getSAE in interface ForecastingModel
Returns:
the sum of absolute errors (SAE) obtained by applying this forecasting model to the initial data set.
Throws:
ModelNotInitializedException - if getSAE is called before the model has been initialized with a call to init.

forecast

public DataSet forecast(DataSet dataSet)
Using the current model parameters (initialized in init), apply the forecast model to the given data set. Each data point in the data set must have valid values for the independent variables. Upon return, the value of the dependent variable will be updated with the forecast values computed. This method is provided as a convenience method, and iterates through the data set invoking forecast(DataPoint) to do the actual forecast for each data point. In general, it is not necessary to override this method. However, if a subclass can provide a more efficient approach then it is recommended that the subclass provide its own implementation.

Specified by:
forecast in interface ForecastingModel
Parameters:
dataSet - the set of data points for which forecast values (for the dependent variable) are required.
Returns:
the same data set passed in but with the dependent values updated to contain the new forecast values.
Throws:
ModelNotInitializedException - if getMSE is called before the model has been initialized with a call to init.

calculateAccuracyIndicators

protected void calculateAccuracyIndicators(DataSet dataSet)
A helper method to calculate the various accuracy indicators when applying the given DataSet to the current forecasting model.

Parameters:
dataSet - the DataSet to use to evaluate this model, and to calculate the accuracy indicators against.


OpenForecast, Copyright (c) Steven Gould, 2002-2011