ses

package
v0.0.0-...-a103044 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ses implements the simple exponential smooting forecasting algorithm.

Index

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

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

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

Predict forecasts the next n values for the loaded data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL