gluonts.ext.r_forecast package#

class gluonts.ext.r_forecast.RBasePredictor(freq: str, prediction_length: int, period: Optional[int] = None, trunc_length: Optional[int] = None, save_info: bool = False, 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 rpy2.

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, **kwargs) Iterator[gluonts.model.forecast.Forecast][source]#

Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.

Returns

Iterator over the forecasts, in the same order as the dataset iterable was provided.

Return type

Iterator[Forecast]

class gluonts.ext.r_forecast.RForecastPredictor(freq: str, prediction_length: int, method_name: str = 'ets', period: Optional[int] = None, trunc_length: Optional[int] = None, save_info: bool = False, params: Dict = {})[source]#

Bases: gluonts.ext.r_forecast._predictor.RBasePredictor

Wrapper for calling the `R forecast package.

<http://pkg.robjhyndman.com/forecast/>`_.

In order to use it you need to install R and rpy2. You also need the R forecast package which can be installed by running:

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. For output_type, ‘mean’ and quantiles are supported (depending on the underlying R method).

class gluonts.ext.r_forecast.RHierarchicalForecastPredictor(freq: str, prediction_length: int, is_hts: bool, target_dim: int, num_bottom_ts: int, nodes: List, method_name: str, fmethod: str, period: Optional[int] = None, trunc_length: Optional[int] = None, save_info: bool = False, nonnegative: bool = False, level: Optional[int] = None, algorithm: Optional[str] = 'cg', covariance: Optional[str] = 'shr', numcores: Optional[int] = None, params: Optional[Dict] = None)[source]#

Bases: gluonts.ext.r_forecast._predictor.RBasePredictor

Wrapper for calling the R hts package.

In order to use it you need to install R and rpy2. You also need the R hts package which can be installed by running:

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: “naive_bottom_up”, “middle_out_w_forecasts_proportions”, “top_down_w_average_historical_proportions”, “top_down_w_proportions_of_the_historical_averages”, “top_down_w_forecasts_proportions”, “mint”, “erm”

  • 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.

  • level – Level of hierarchy to be used as reference for middle out reconciliation (i.e. level=1 means that the level below the highest one will be used as reference to compute the forecasts of all the other levels). This value is required only for middle out.

  • numcores – Number of cores to be used for parallelization of ERM. If not provided, all cores will be used.