gluonts.model.r_forecast package#

class gluonts.model.r_forecast.RBasePredictor(freq: str, prediction_length: int, period: int = None, trunc_length: Optional[int] = None, r_file_prefix: str = '')[source]#

Bases: gluonts.model.predictor.RepresentablePredictor

The RBasePredictor is a thin wrapper for calling R packages. In order to use it you need to install R and run:

pip install 'rpy2>=2.9.*,<3.*'

Note that specific R packages need to be installed, depending on which wrapper one needs to run. See RForecastPredictor and RHierarchicalForecastPredictor to know which packages are needed.

Parameters
  • freq – The granularity of the time series (e.g. ‘1H’)

  • prediction_length – Number of time points to be predicted.

  • period – The period to be used (this is called frequency in the R forecast package), result to a tentative reasonable default if not specified (for instance 24 for hourly freq ‘1H’)

  • trunc_length – Maximum history length to feed to the model (some models become slow with very long series).

  • r_file_prefix – Prefix string of the R file(s) where our forecasting wrapper methods can be found. This is to avoid loading all R files potentially having different implementations of the same method, thereby making sure the expected R method is in fact used.

predict(dataset: gluonts.dataset.Dataset, num_samples: int = 100, intervals: Optional[List] = None, save_info: bool = False, **kwargs) Iterator[gluonts.model.forecast.Forecast][source]#
Parameters
  • dataset – Dataset of all time series.

  • num_samples – Number of samples to store in sample based forecast.

  • intervals – Prediction intervals for the quantile based forecast.

  • save_info – Should console output from R methods be saved?

  • kwargs

Returns

Iterator over gluonts Forecast object.

Return type

Iterator[Forecast]

class gluonts.model.r_forecast.RForecastPredictor(freq: str, prediction_length: int, method_name: str = 'ets', period: int = None, trunc_length: Optional[int] = None, params: Optional[Dict] = None)[source]#

Bases: gluonts.model.r_forecast._predictor.RBasePredictor

Wrapper for calling the R forecast package.

In order to use it you need to install R and run:

pip install 'rpy2>=2.9.*,<3.*'
R -e 'install.packages(c("forecast", "nnfor"), repos="https://cloud.r-project.org")' # noqa
Parameters
  • freq – The granularity of the time series (e.g. ‘1H’)

  • prediction_length – Number of time points to be predicted.

  • method_name – The method from rforecast to be used one of “ets”, “arima”, “tbats”, “croston”, “mlp”, “thetaf”.

  • period – The period to be used (this is called frequency in the R forecast package), result to a tentative reasonable default if not specified (for instance 24 for hourly freq ‘1H’)

  • trunc_length – Maximum history length to feed to the model (some models become slow with very long series).

  • params – Parameters to be used when calling the forecast method default. Note that, as output_type, only ‘samples’ and quantiles (depending on the underlying R method) are supported currently.

class gluonts.model.r_forecast.RHierarchicalForecastPredictor(freq: str, prediction_length: int, is_hts: bool, target_dim: int, num_bottom_ts: int, nodes: List, nonnegative: bool, method_name: str, fmethod: str, period: int = None, trunc_length: Optional[int] = None, params: Optional[Dict] = None)[source]#

Bases: gluonts.model.r_forecast._predictor.RBasePredictor

Wrapper for calling the R hts package.

In order to use it you need to install R and run

pip install rpy2 R -e ‘install.packages(c(“hts”), repos=”https://cloud.r-project.org”)’

Parameters
  • freq – The granularity of the time series (e.g. ‘1H’)

  • prediction_length – Number of time points to be predicted.

  • is_hts – Is the time series a hierarchical one as opposed to a grouped time series. # noqa

  • target_dim – The dimension (size) of the multivariate target time series.

  • num_bottom_ts – Number of bottom time series in the hierarchy.

  • nodes – Node structure representing the hierarchichy as defined in the hts package. To know the exact strucutre of nodes see the help: Hierarhical: https://stackoverflow.com/questions/13579292/how-to-use-hts-with-multi-level-hierarchies Grouped: https://robjhyndman.com/hyndsight/gts/

  • nonnegative – Is the target non-negative?

  • method_name – Hierarchical forecasting or reconciliation method to be used; mutst be one of: “mint”, “naive_bottom_up”, “erm”, “mint_ols”, “depbu_mint”, “ermParallel”

  • fmethod – The forecasting method to be used for generating base forecasts (i.e., un-reconciled forecasts).

  • period – The period to be used (this is called frequency in the R forecast package), result to a tentative reasonable default if not specified (for instance 24 for hourly freq ‘1H’)

  • trunc_length – Maximum history length to feed to the model (some models become slow with very long series).

  • params – Parameters to be used when calling the forecast method default. Note that, as output_type, only ‘samples’ is supported currently.