class_docstr: Creates a population of similar time series.
  
  This method utilises a form of bootstrapping to generate a population of
  similar time series to the input time series [1]_, [2]_.
  
  First the observed time series is transformed using a Box-Cox transformation to
  stabilise the variance. Then it's decomposed to seasonal, trend and residual
  time series, using the STL implementation from statsmodels
  (``statsmodels.tsa.api.STL``) [4]_. We then sample blocks from the residuals time
  series using the Moving Block Bootstrapping (MBB) method [3]_ to create synthetic
  residuals series that mimic the autocorrelation patterns of the observed series.
  Finally these bootstrapped residuals are added to the season and trend components
  and we use the inverse Box-Cox transform to return a panel of similar time series.
  The output can be used for bagging forecasts, prediction intervals and data
  augmentation.
  
  The returned panel will be a multiindex dataframe (``pd.DataFrame``) with the
  series_id and time_index as the index and a single column of the time series value.
  The values for series_id are "actual" for the original series and "synthetic_n"
  (where n is an integer) for the generated series.
  See the **Examples** section for example output.
  
  Parameters
  ----------
  n_series : int, optional
      The number of bootstrapped time series that will be generated, by default 10.
  sp : int, optional
      Seasonal periodicity of the data in integer form, by default 12.
      Must be an integer >= 2
  block_length : int, optional
      The length of the block in the MBB method, by default None.
      If not provided, the following heuristic is used, the block length will the
      minimum between 2*sp and len(X) - sp.
  sampling_replacement : bool, optional
      Whether the MBB sample is with or without replacement, by default False.
  return_actual : bool, optional
      If True the output will contain the actual time series, by default True.
      The actual time series will be labelled as "<series_name>_actual" (or "actual"
      if series name is None).
  lambda_bounds : Tuple, optional
      BoxCox parameter:
      Lower and upper bounds used to restrict the feasible range
      when solving for the value of lambda, by default None.
  lambda_method : str, optional
      BoxCox parameter:
      {"pearsonr", "mle", "all", "guerrero"}, by default "guerrero".
      The optimization approach used to determine the lambda value used
      in the Box-Cox transformation.
  seasonal : int, optional
      STL parameter:
      Length of the seasonal smoother. Must be an odd integer, and should
      normally be >= 7, by default 7.
  trend : int, optional
      STL parameter:
      Length of the trend smoother, by default None.
      Must be an odd integer. If not provided uses the smallest odd integer greater
      than 1.5 * period / (1 - 1.5 / seasonal), following the suggestion in the
      original implementation.
  low_pass : int, optional
      STL parameter:
      Length of the low-pass filter, by default None.
      Must be an odd integer >=3. If not provided, uses the smallest odd
      integer > period
  seasonal_deg : int, optional
      STL parameter:
      Degree of seasonal LOESS. 0 (constant) or 1 (constant and trend), by default 1.
  trend_deg : int, optional
      STL parameter:
      Degree of trend LOESS. 0 (constant) or 1 (constant and trend), by default 1.
  low_pass_deg : int, optional
      STL parameter:
      Degree of low pass LOESS. 0 (constant) or 1 (constant and trend), by default 1.
  robust : bool, optional
      STL parameter:
      Flag indicating whether to use a weighted version that is robust to
      some forms of outliers, by default False.
  seasonal_jump : int, optional
      STL parameter:
      Positive integer determining the linear interpolation step, by default 1.
      If larger than 1, the LOESS is used every seasonal_jump points and linear
      interpolation is between fitted points. Higher values reduce estimation time.
  trend_jump : int, optional
      STL parameter:
      Positive integer determining the linear interpolation step, by default 1.
      If larger than 1, the LOESS is used every trend_jump points and values between
      the two are linearly interpolated. Higher values reduce estimation time.
  low_pass_jump : int, optional
      STL parameter:
      Positive integer determining the linear interpolation step, by default 1.
      If larger than 1, the LOESS is used every low_pass_jump points and values
      between the two are linearly interpolated. Higher values reduce estimation
      time.
  inner_iter : int, optional
      STL parameter:
      Number of iterations to perform in the inner loop, by default None.
      If not provided uses 2 if robust is True, or 5 if not. This param goes into
      STL.fit() from statsmodels.
  outer_iter : int, optional
      STL parameter:
      Number of iterations to perform in the outer loop, by default None.
      If not provided uses 15 if robust is True, or 0 if not.
      This param goes into STL.fit() from statsmodels.
  random_state : int, np.random.RandomState or None, by default None
      Controls the randomness of the estimator
  
  See Also
  --------
  sktime.transformations.bootstrap.MovingBlockBootstrapTransformer :
      Transformer that applies the Moving Block Bootstrapping method to create
      a panel of synthetic time series.
  
  References
  ----------
  .. [1] 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
  .. [2] 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.
  .. [3] Kunsch HR (1989) The jackknife and the bootstrap for general stationary
      observations. Annals of Statistics 17(3), 1217-1241
  .. [4] https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.STL.html
  
  Examples
  --------
  >>> from sktime.transformations.bootstrap import STLBootstrapTransformer
  >>> from sktime.datasets import load_airline
  >>> from sktime.utils.plotting import plot_series  # doctest: +SKIP
  >>> y = load_airline()  # doctest: +SKIP
  >>> transformer = STLBootstrapTransformer(10)  # doctest: +SKIP
  >>> y_hat = transformer.fit_transform(y)  # doctest: +SKIP
  >>> series_list = []  # doctest: +SKIP
  >>> names = []  # doctest: +SKIP
  >>> for group, series in y_hat.groupby(level=[0], as_index=False):
  ...     series.index = series.index.droplevel(0)
  ...     series_list.append(series)
  ...     names.append(group)  # doctest: +SKIP
  >>> plot_series(*series_list, labels=names)  # doctest: +SKIP
  (...)
  >>> print(y_hat.head())  # doctest: +SKIP
                        Number of airline passengers
  series_id time_index
  actual    1949-01                            112.0
            1949-02                            118.0
            1949-03                            132.0
            1949-04                            129.0
            1949-05                            121.0
class_docstr_tok: ["Creates","a","population","of","similar","time","series",".","This","method","utilises","a","form","of","bootstrapping","to","generate","a","population","of","similar","time","series","to","the","input","time","series","[","1","]","_",",","[","2","]","_",".","First","the","observed","time","series","is","transformed","using","a","Box-Cox","transformation","to","stabilise","the","variance",".","Then","it","'s","decomposed","to","seasonal",",","trend","and","residual","time","series",",","using","the","STL","implementation","from","statsmodels","(","``","statsmodels.tsa.api.STL","``",")","[","4","]","_",".","We","then","sample","blocks","from","the","residuals","time","series","using","the","Moving","Block","Bootstrapping","(","MBB",")","method","[","3","]","_","to","create","synthetic","residuals","series","that","mimic","the","autocorrelation","patterns","of","the","observed","series",".","Finally","these","bootstrapped","residuals","are","added","to","the","season","and","trend","components","and","we","use","the","inverse","Box-Cox","transform","to","return","a","panel","of","similar","time","series",".","The","output","can","be","used","for","bagging","forecasts",",","prediction","intervals","and","data","augmentation",".","The","returned","panel","will","be","a","multiindex","dataframe","(","``","pd.DataFrame","``",")","with","the","series_id","and","time_index","as","the","index","and","a","single","column","of","the","time","series","value",".","The","values","for","series_id","are","``","actual","''","for","the","original","series","and","``","synthetic_n","''","(","where","n","is","an","integer",")","for","the","generated","series",".","See","the","*","*","Examples","*","*","section","for","example","output",".","Parameters","--","--","--","--","--","n_series",":","int",",","optional","The","number","of","bootstrapped","time","series","that","will","be","generated",",","by","default","10.","sp",":","int",",","optional","Seasonal","periodicity","of","the","data","in","integer","form",",","by","default","12",".","Must","be","an","integer",">","=","2","block_length",":","int",",","optional","The","length","of","the","block","in","the","MBB","method",",","by","default","None",".","If","not","provided",",","the","following","heuristic","is","used",",","the","block","length","will","the","minimum","between","2","*","sp","and","len","(","X",")","-","sp",".","sampling_replacement",":","bool",",","optional","Whether","the","MBB","sample","is","with","or","without","replacement",",","by","default","False",".","return_actual",":","bool",",","optional","If","True","the","output","will","contain","the","actual","time","series",",","by","default","True",".","The","actual","time","series","will","be","labelled","as","``","<","series_name",">","_actual","''","(","or","``","actual","''","if","series","name","is","None",")",".","lambda_bounds",":","Tuple",",","optional","BoxCox","parameter",":","Lower","and","upper","bounds","used","to","restrict","the","feasible","range","when","solving","for","the","value","of","lambda",",","by","default","None",".","lambda_method",":","str",",","optional","BoxCox","parameter",":","{","``","pearsonr","''",",","``","mle","''",",","``","all","''",",","``","guerrero","''","}",",","by","default","``","guerrero","''",".","The","optimization","approach","used","to","determine","the","lambda","value","used","in","the","Box-Cox","transformation",".","seasonal",":","int",",","optional","STL","parameter",":","Length","of","the","seasonal","smoother",".","Must","be","an","odd","integer",",","and","should","normally","be",">","=","7",",","by","default","7.","trend",":","int",",","optional","STL","parameter",":","Length","of","the","trend","smoother",",","by","default","None",".","Must","be","an","odd","integer",".","If","not","provided","uses","the","smallest","odd","integer","greater","than","1.5","*","period","\/","(","1","-","1.5","\/","seasonal",")",",","following","the","suggestion","in","the","original","implementation",".","low_pass",":","int",",","optional","STL","parameter",":","Length","of","the","low-pass","filter",",","by","default","None",".","Must","be","an","odd","integer",">","=3",".","If","not","provided",",","uses","the","smallest","odd","integer",">","period","seasonal_deg",":","int",",","optional","STL","parameter",":","Degree","of","seasonal","LOESS",".","0","(","constant",")","or","1","(","constant","and","trend",")",",","by","default","1.","trend_deg",":","int",",","optional","STL","parameter",":","Degree","of","trend","LOESS",".","0","(","constant",")","or","1","(","constant","and","trend",")",",","by","default","1.","low_pass_deg",":","int",",","optional","STL","parameter",":","Degree","of","low","pass","LOESS",".","0","(","constant",")","or","1","(","constant","and","trend",")",",","by","default","1.","robust",":","bool",",","optional","STL","parameter",":","Flag","indicating","whether","to","use","a","weighted","version","that","is","robust","to","some","forms","of","outliers",",","by","default","False",".","seasonal_jump",":","int",",","optional","STL","parameter",":","Positive","integer","determining","the","linear","interpolation","step",",","by","default","1",".","If","larger","than","1",",","the","LOESS","is","used","every","seasonal_jump","points","and","linear","interpolation","is","between","fitted","points",".","Higher","values","reduce","estimation","time",".","trend_jump",":","int",",","optional","STL","parameter",":","Positive","integer","determining","the","linear","interpolation","step",",","by","default","1",".","If","larger","than","1",",","the","LOESS","is","used","every","trend_jump","points","and","values","between","the","two","are","linearly","interpolated",".","Higher","values","reduce","estimation","time",".","low_pass_jump",":","int",",","optional","STL","parameter",":","Positive","integer","determining","the","linear","interpolation","step",",","by","default","1",".","If","larger","than","1",",","the","LOESS","is","used","every","low_pass_jump","points","and","values","between","the","two","are","linearly","interpolated",".","Higher","values","reduce","estimation","time",".","inner_iter",":","int",",","optional","STL","parameter",":","Number","of","iterations","to","perform","in","the","inner","loop",",","by","default","None",".","If","not","provided","uses","2","if","robust","is","True",",","or","5","if","not",".","This","param","goes","into","STL.fit","(",")","from","statsmodels",".","outer_iter",":","int",",","optional","STL","parameter",":","Number","of","iterations","to","perform","in","the","outer","loop",",","by","default","None",".","If","not","provided","uses","15","if","robust","is","True",",","or","0","if","not",".","This","param","goes","into","STL.fit","(",")","from","statsmodels",".","random_state",":","int",",","np.random.RandomState","or","None",",","by","default","None","Controls","the","randomness","of","the","estimator","See","Also","--","--","--","--","sktime.transformations.bootstrap.MovingBlockBootstrapTransformer",":","Transformer","that","applies","the","Moving","Block","Bootstrapping","method","to","create","a","panel","of","synthetic","time","series",".","References","--","--","--","--","--","..","[","1","]","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","..","[","2","]","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",".","..","[","3","]","Kunsch","HR","(","1989",")","The","jackknife","and","the","bootstrap","for","general","stationary","observations",".","Annals","of","Statistics","17","(","3",")",",","1217-1241","..","[","4","]","https",":","\/\/www.statsmodels.org\/dev\/generated\/statsmodels.tsa.seasonal.STL.html","Examples","--","--","--","--",">",">",">","from","sktime.transformations.bootstrap","import","STLBootstrapTransformer",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","from","sktime.utils.plotting","import","plot_series","#","doctest",":","+SKIP",">",">",">","y","=","load_airline","(",")","#","doctest",":","+SKIP",">",">",">","transformer","=","STLBootstrapTransformer","(","10",")","#","doctest",":","+SKIP",">",">",">","y_hat","=","transformer.fit_transform","(","y",")","#","doctest",":","+SKIP",">",">",">","series_list","=","[","]","#","doctest",":","+SKIP",">",">",">","names","=","[","]","#","doctest",":","+SKIP",">",">",">","for","group",",","series","in","y_hat.groupby","(","level=","[","0","]",",","as_index=False",")",":","...","series.index","=","series.index.droplevel","(","0",")","...","series_list.append","(","series",")","...","names.append","(","group",")","#","doctest",":","+SKIP",">",">",">","plot_series","(","*","series_list",",","labels=names",")","#","doctest",":","+SKIP","(","...",")",">",">",">","print","(","y_hat.head","(",")",")","#","doctest",":","+SKIP","Number","of","airline","passengers","series_id","time_index","actual","1949-01","112.0","1949-02","118.0","1949-03","132.0","1949-04","129.0","1949-05","121.0"]
docstr: Transform X and return a transformed version.
  
  private _transform containing core logic, called from transform
  
  Parameters
  ----------
  X : pd.Series
      Data to be transformed
  y : ignored, for interface compatibility
  
  Returns
  -------
  transformed version of X
docstr_tok: ["Transform","X","and","return","a","transformed","version",".","private","_transform","containing","core","logic",",","called","from","transform","Parameters","--","--","--","--","--","X",":","pd.Series","Data","to","be","transformed","y",":","ignored",",","for","interface","compatibility","Returns","--","--","--","-","transformed","version","of","X"]
code: def _transform(self, X, y=None):
      """Transform X and return a transformed version.
  
      private _transform containing core logic, called from transform
  
      Parameters
      ----------
      X : pd.Series
          Data to be transformed
      y : ignored, for interface compatibility
  
      Returns
      -------
      transformed version of X
      """
      from statsmodels.tsa.api import STL as _STL
  
      Xcol = X.columns
      X = X[X.columns[0]]
  
      if len(X) <= self.block_length_:
          raise ValueError(
              "STLBootstrapTransformer requires that block_length is"
              " strictly smaller than the length of X"
          )
  
      X_index = X.index
      X_transformed = self.box_cox_transformer_.transform(X)
  
      # fit STL on X_transformed series and extract trend, seasonal and residuals
      stl = _STL(
          X_transformed,
          period=self.sp,
          seasonal=self.seasonal,
          trend=self.trend,
          low_pass=self.low_pass,
          seasonal_deg=self.seasonal_deg,
          trend_deg=self.trend_deg,
          low_pass_deg=self.low_pass_deg,
          robust=self.robust,
          seasonal_jump=self.seasonal_jump,
          trend_jump=self.trend_jump,
          low_pass_jump=self.low_pass_jump,
      ).fit(inner_iter=self.inner_iter, outer_iter=self.outer_iter)
      seasonal = pd.Series(stl.seasonal, index=X_index)
      resid = pd.Series(stl.resid, index=X_index)
      trend = pd.Series(stl.trend, index=X_index)
  
      # time series id prefix
      col_name = _get_series_name(X)
  
      # initialize the dataframe that will store the bootstrapped series
      if self.return_actual:
          df_list = [
              pd.DataFrame(
                  X.values,
                  index=pd.MultiIndex.from_product(
                      iterables=[["actual"], X_index],
                      names=["series_id", "time_index"],
                  ),
                  columns=[col_name],
              )
          ]
      else:
          df_list = []
  
      # set the random state
      rng = check_random_state(self.random_state)
      # create multiple series
      for i in range(self.n_series):
          new_series = self.box_cox_transformer_.inverse_transform(
              _moving_block_bootstrap(
                  ts=resid,
                  block_length=self.block_length_,
                  replacement=self.sampling_replacement,
                  random_state=rng,
              )
              + seasonal
              + trend
          )
  
          new_series_id = f"synthetic_{i}"
          new_df_index = pd.MultiIndex.from_product(
              iterables=[[new_series_id], new_series.index],
              names=["series_id", "time_index"],
          )
  
          df_list.append(
              pd.DataFrame(
                  data=new_series.values,
                  index=new_df_index,
                  columns=[col_name],
              )
          )
  
      Xt = pd.concat(df_list)
      Xt.columns = Xcol
  
      return Xt
  
imports: from copy import copy
  from typing import Tuple, Union
  import numpy
  import pandas
  from sklearn.utils import check_random_state
  from sktime.transformations.base import BaseTransformer
  from sktime.transformations.series.boxcox import BoxCoxTransformer
label_desc: Use image node_id 3 for calling the STLBootstrapTransformer obj's underlying member method code with example usage: obj._transform(X, y) and returns: Xt