class_docstr: 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_docstr_tok: ["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",")","."]
code: def __init__(
      self,
      freq: str,
      prediction_length: int,
      method_name: str = "ets",
      period: Optional[int] = None,
      trunc_length: Optional[int] = None,
      save_info: bool = False,
      params: Dict = dict(),
  ) -> None:
      super().__init__(
          freq=freq,
          prediction_length=prediction_length,
          period=period,
          trunc_length=trunc_length,
          save_info=save_info,
          r_file_prefix="univariate",
      )
      assert method_name in SUPPORTED_UNIVARIATE_METHODS, (
          f"method {method_name} is not supported please "
          f"use one of {SUPPORTED_UNIVARIATE_METHODS}"
      )
  
      self.method_name = method_name
      self._r_method = self._robjects.r[method_name]
  
      self.params: Dict[str, Any] = {
          "prediction_length": self.prediction_length,
          "frequency": self.period,
      }
  
      if self.method_name in UNIVARIATE_POINT_FORECAST_METHODS:
          self.params["output_types"] = ["mean"]
      elif self.method_name in UNIVARIATE_QUANTILE_FORECAST_METHODS:
          self.params["output_types"] = ["mean", "quantiles"]
          self.params["intervals"] = list(range(0, 100, 10))
  
      if "quantiles" in params:
          assert (
              "intervals" not in params
          ), "Cannot specify both 'quantiles' and 'intervals'."
          intervals_info = [
              quantile_to_interval_level(ql)
              for ql in params["quantiles"]
          ]
          params["intervals"] = sorted(
              set([level for level, _ in intervals_info])
          )
          params.pop("quantiles")
  
      self.params.update(params)
  
      # Always ask for the mean prediction to be given,
      # since QuantileForecast will otherwise impute it
      # using the median, which is undesired.
      if "mean" not in self.params["output_types"]:
          self.params["output_types"].append("mean")
  
file_path: gluonts/src/gluonts/ext/r_forecast/_univariate_predictor.py
imports: from typing import Dict, Optional, Any
  import numpy
  import pandas
  from gluonts.core.component import validated
  from gluonts.model.forecast import QuantileForecast
  from .None import RBasePredictor
  from .util import unlist, quantile_to_interval_level, interval_to_quantile_level
label_desc: Use image node_id 1 to create a new RForecastPredictor object from inherited base classes: RBasePredictor with example: obj = RForecastPredictor(freq, prediction_length, method_name, period, trunc_length, save_info, params)