gluonts.model.trivial.mean module#

class gluonts.model.trivial.mean.MeanEstimator(prediction_length: PositiveInt, num_samples: PositiveInt)[source]#

Bases: Estimator

An Estimator that computes the mean targets in the training data, in the trailing prediction_length observations, and produces a ConstantPredictor that always predicts such mean value.

Parameters:
  • prediction_length (int) – Prediction horizon.

  • num_samples – Number of samples to include in the forecasts. Not that the samples produced by this predictor will all be identical.

train(training_data: Dataset, validation_dataset: Optional[Dataset] = None) ConstantPredictor[source]#

Train the estimator on the given data.

Parameters:
  • training_data – Dataset to train the model on.

  • validation_data – Dataset to validate the model on during training.

Returns:

The predictor containing the trained model.

Return type:

Predictor

class gluonts.model.trivial.mean.MeanPredictor(prediction_length: int, num_samples: int = 100, context_length: Optional[int] = None)[source]#

Bases: RepresentablePredictor

A Predictor that predicts the samples based on the mean of the last context_length elements of the input target.

Parameters:
  • context_length – Length of the target context used to condition the predictions.

  • prediction_length – Length of the prediction horizon.

  • num_samples – Number of samples to use to construct SampleForecast objects for every prediction.

predict_item(item: Dict[str, Any]) SampleForecast[source]#
class gluonts.model.trivial.mean.MovingAveragePredictor(prediction_length: int, context_length: Optional[int] = None)[source]#

Bases: RepresentablePredictor

A Predictor that predicts the moving average based on the last context_length elements of the input target.

If prediction_length = 1, the output is the moving average based on the last context_length elements of the input target.

If prediction_length > 1, the output is the moving average based on the last context_length elements of the input target, where previously calculated moving averages are appended at the end of the inputtarget. Hence, for prediction_length larger than context_length, there will be cases where the moving average is calculated on top of previous moving averages.

Parameters:
  • context_length – Length of the target context used to condition the predictions.

  • prediction_length – Length of the prediction horizon.

predict_item(item: Dict[str, Any]) SampleForecast[source]#