class_docstr: Forecast a time series by aggregating forecasts from its bootstraps.
  
  Bagged "Bootstrap Aggregating" Forecasts are obtained by forecasting bootstrapped
  time series and then aggregating the resulting forecasts. For the point forecast,
  the different forecasts are aggregated using the mean function [1]. Prediction
  intervals and quantiles are calculated for each time point in the forecasting
  horizon by calculating the sampled forecast quantiles.
  
  Bergmeir et al. (2016) [2] show that, on average, bagging ETS forecasts gives better
  forecasts than just applying ETS directly. The default bootstrapping transformer
  and forecaster are selected as in [2].
  
  Parameters
  ----------
  bootstrap_transformer : BaseTransformer
      (sktime.transformations.bootstrap.STLBootstrapTransformer)
      Bootstrapping Transformer that takes a series (with tag
      scitype:transform-input=Series) as input and returns a panel (with tag
      scitype:transform-input=Panel) of bootstrapped time series if not specified
      sktime.transformations.bootstrap.STLBootstrapTransformer is used.
  forecaster : BaseForecaster (sktime.forecating.ets.AutoETS)
      A valid sktime Forecaster. If not specified sktime.forecating.ets.AutoETS is
      used.
  sp: int (default=2)
      Seasonal period for default Forecaster and Transformer. Must be 2 or greater.
      Ignored for the bootstrap_transformer and forecaster if they are specified.
  random_state: int or np.random.RandomState (default=None)
      The random state of the estimator, used to control the random number generator
  
  See Also
  --------
  sktime.transformations.bootstrap.MovingBlockBootstrapTransformer :
      Transformer that applies the Moving Block Bootstrapping method to create
      a panel of synthetic time series.
  
  sktime.transformations.bootstrap.STLBootstrapTransformer :
      Transformer that utilises BoxCox, STL and Moving Block Bootstrapping to create
      a panel of similar time series.
  
  References
  ----------
  .. [1] Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and
      practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3,
      Chapter 12.5. Accessed on February 13th 2022.
  .. [2] Bergmeir, C., Hyndman, R. J., & Benítez, J. M. (2016). Bagging exponential
      smoothing methods using STL decomposition and Box-Cox transformation.
      International Journal of Forecasting, 32(2), 303-312
  
  Examples
  --------
  >>> from sktime.transformations.bootstrap import STLBootstrapTransformer
  >>> from sktime.forecasting.naive import NaiveForecaster
  >>> from sktime.forecasting.compose import BaggingForecaster
  >>> from sktime.datasets import load_airline
  >>> y = load_airline()
  >>> forecaster = BaggingForecaster(
  ...     STLBootstrapTransformer(sp=12), NaiveForecaster(sp=12)
  ... )  # doctest: +SKIP
  >>> forecaster.fit(y)  # doctest: +SKIP
  BaggingForecaster(...)
  >>> y_hat = forecaster.predict([1,2,3])  # doctest: +SKIP
class_docstr_tok: ["Forecast","a","time","series","by","aggregating","forecasts","from","its","bootstraps",".","Bagged","``","Bootstrap","Aggregating","''","Forecasts","are","obtained","by","forecasting","bootstrapped","time","series","and","then","aggregating","the","resulting","forecasts",".","For","the","point","forecast",",","the","different","forecasts","are","aggregated","using","the","mean","function","[","1","]",".","Prediction","intervals","and","quantiles","are","calculated","for","each","time","point","in","the","forecasting","horizon","by","calculating","the","sampled","forecast","quantiles",".","Bergmeir","et","al",".","(","2016",")","[","2","]","show","that",",","on","average",",","bagging","ETS","forecasts","gives","better","forecasts","than","just","applying","ETS","directly",".","The","default","bootstrapping","transformer","and","forecaster","are","selected","as","in","[","2","]",".","Parameters","--","--","--","--","--","bootstrap_transformer",":","BaseTransformer","(","sktime.transformations.bootstrap.STLBootstrapTransformer",")","Bootstrapping","Transformer","that","takes","a","series","(","with","tag","scitype",":","transform-input=Series",")","as","input","and","returns","a","panel","(","with","tag","scitype",":","transform-input=Panel",")","of","bootstrapped","time","series","if","not","specified","sktime.transformations.bootstrap.STLBootstrapTransformer","is","used",".","forecaster",":","BaseForecaster","(","sktime.forecating.ets.AutoETS",")","A","valid","sktime","Forecaster",".","If","not","specified","sktime.forecating.ets.AutoETS","is","used",".","sp",":","int","(","default=2",")","Seasonal","period","for","default","Forecaster","and","Transformer",".","Must","be","2","or","greater",".","Ignored","for","the","bootstrap_transformer","and","forecaster","if","they","are","specified",".","random_state",":","int","or","np.random.RandomState","(","default=None",")","The","random","state","of","the","estimator",",","used","to","control","the","random","number","generator","See","Also","--","--","--","--","sktime.transformations.bootstrap.MovingBlockBootstrapTransformer",":","Transformer","that","applies","the","Moving","Block","Bootstrapping","method","to","create","a","panel","of","synthetic","time","series",".","sktime.transformations.bootstrap.STLBootstrapTransformer",":","Transformer","that","utilises","BoxCox",",","STL","and","Moving","Block","Bootstrapping","to","create","a","panel","of","similar","time","series",".","References","--","--","--","--","--","..","[","1","]","Hyndman",",","R.J.",",","&","Athanasopoulos",",","G.","(","2021",")","Forecasting",":","principles","and","practice",",","3rd","edition",",","OTexts",":","Melbourne",",","Australia",".","OTexts.com\/fpp3",",","Chapter","12.5",".","Accessed","on","February","13th","2022",".","..","[","2","]","Bergmeir",",","C.",",","Hyndman",",","R.","J.",",","&","Ben\u00edtez",",","J.","M.","(","2016",")",".","Bagging","exponential","smoothing","methods","using","STL","decomposition","and","Box-Cox","transformation",".","International","Journal","of","Forecasting",",","32","(","2",")",",","303-312","Examples","--","--","--","--",">",">",">","from","sktime.transformations.bootstrap","import","STLBootstrapTransformer",">",">",">","from","sktime.forecasting.naive","import","NaiveForecaster",">",">",">","from","sktime.forecasting.compose","import","BaggingForecaster",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","y","=","load_airline","(",")",">",">",">","forecaster","=","BaggingForecaster","(","...","STLBootstrapTransformer","(","sp=12",")",",","NaiveForecaster","(","sp=12",")","...",")","#","doctest",":","+SKIP",">",">",">","forecaster.fit","(","y",")","#","doctest",":","+SKIP","BaggingForecaster","(","...",")",">",">",">","y_hat","=","forecaster.predict","(","[","1,2,3","]",")","#","doctest",":","+SKIP"]
docstr: Generate quantiles for each time point.
  
  Parameters
  ----------
  df : pd.DataFrame
      A dataframe of mtype pd-multiindex or hierarchical
  alpha : List[float]
      list of the desired quantiles
  
  Returns
  -------
  pd.DataFrame
      The specified quantiles
docstr_tok: ["Generate","quantiles","for","each","time","point",".","Parameters","--","--","--","--","--","df",":","pd.DataFrame","A","dataframe","of","mtype","pd-multiindex","or","hierarchical","alpha",":","List","[","float","]","list","of","the","desired","quantiles","Returns","--","--","--","-","pd.DataFrame","The","specified","quantiles"]
code: def _calculate_data_quantiles(
      self, df: pd.DataFrame, alpha: List[float]
  ):
      """Generate quantiles for each time point.
  
      Parameters
      ----------
      df : pd.DataFrame
          A dataframe of mtype pd-multiindex or hierarchical
      alpha : List[float]
          list of the desired quantiles
  
      Returns
      -------
      pd.DataFrame
          The specified quantiles
      """
      var_names = self._get_varnames()
      var_name = var_names[0]
  
      index = pd.MultiIndex.from_product([var_names, alpha])
      pred_quantiles = pd.DataFrame(columns=index)
      for a in alpha:
          quant_a = df.groupby(level=-1, as_index=True).quantile(a)
          pred_quantiles[[(var_name, a)]] = quant_a
  
      return pred_quantiles
  
imports: from typing import List, Union
  import numpy
  import pandas
  from sklearn import clone
  from sklearn.utils import check_random_state
  from sktime.datatypes._utilities import update_data
  from sktime.forecasting.base import BaseForecaster
  from sktime.forecasting.ets import AutoETS
  from sktime.transformations.base import BaseTransformer
  from sktime.transformations.bootstrap import MovingBlockBootstrapTransformer, STLBootstrapTransformer
  from sktime.utils.estimators import MockForecaster
  from sktime.utils.random_state import set_random_state
label_desc: Use image node_id 7 for calling the BaggingForecaster obj's underlying member method code with example usage: obj._calculate_data_quantiles(df, alpha) and returns: pred_quantiles