Documentation
¶
Overview ¶
Package ses implements the simple exponential smooting forecasting algorithm.
Index ¶
- type ExponentialSmoothingConfig
- type SimpleExpSmoothing
- func (se *SimpleExpSmoothing) Configure(config interface{}) error
- func (se *SimpleExpSmoothing) Evaluate(ctx context.Context, sf *dataframe.SeriesFloat64, ...) (float64, error)
- func (se *SimpleExpSmoothing) Load(ctx context.Context, sf *dataframe.SeriesFloat64, r *dataframe.Range) error
- func (se *SimpleExpSmoothing) Predict(ctx context.Context, n uint) (*dataframe.SeriesFloat64, []forecast.Confidence, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExponentialSmoothingConfig ¶
type ExponentialSmoothingConfig struct { // Alpha must be between 0 and 1. The closer Alpha is to 1, the more the algorithm // prioritizes recent values over past values. Alpha float64 // ConfidenceLevels are values between 0 and 1 (exclusive) that return the associated // confidence intervals for each forecasted value. // // See: https://otexts.com/fpp2/prediction-intervals.html ConfidenceLevels []float64 }
ExponentialSmoothingConfig is used to configure the SES algorithm. SES models the error, trend and seasonal elements of the data with exponential smoothing.
NOTE: SES algorithm does not tolerate nil values. You may need to use the interpolation subpackage.
func (*ExponentialSmoothingConfig) Validate ¶
func (cfg *ExponentialSmoothingConfig) Validate() error
Validate checks if the config is valid.
type SimpleExpSmoothing ¶
type SimpleExpSmoothing struct {
// contains filtered or unexported fields
}
SimpleExpSmoothing represents the SES algorithm for time-series forecasting. It uses the bootstrapping method found here: https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc432.htm
func NewExponentialSmoothing ¶
func NewExponentialSmoothing() *SimpleExpSmoothing
NewExponentialSmoothing creates a new SimpleExpSmoothing object.
func (*SimpleExpSmoothing) Configure ¶
func (se *SimpleExpSmoothing) Configure(config interface{}) error
Configure sets the various parameters for the SES algorithm. config must be a ExponentialSmoothingConfig.
func (*SimpleExpSmoothing) Evaluate ¶
func (se *SimpleExpSmoothing) Evaluate(ctx context.Context, sf *dataframe.SeriesFloat64, evalFunc forecast.EvaluationFunc) (float64, error)
Evaluate will measure the quality of the predicted values based on the evaluation calculation defined by evalFunc. It will compare the error between sf and the values from the end of the loaded data ("validation set"). sf is usually the output of the Predict method.
NOTE: You can use the functions directly from the validation subpackage if you need to do something other than that described above.
func (*SimpleExpSmoothing) Load ¶
func (se *SimpleExpSmoothing) Load(ctx context.Context, sf *dataframe.SeriesFloat64, r *dataframe.Range) error
Load loads historical data. r is used to limit which rows of sf are loaded. Prediction will always begin from the row after that defined by r. r can be thought of as defining a "training set".
NOTE: SES algorithm does not tolerate nil values. You may need to use the interpolation subpackage.
func (*SimpleExpSmoothing) Predict ¶
func (se *SimpleExpSmoothing) Predict(ctx context.Context, n uint) (*dataframe.SeriesFloat64, []forecast.Confidence, error)
Predict forecasts the next n values for the loaded data.