class_docstr: Fourier Features for time series seasonality.
  
  Fourier Series terms can be used as explanatory variables for the cases of multiple
  seasonal periods and or complex / long seasonal periods [1]_, [2]_. For every
  seasonal period, :math:`sp` and fourier term :math:`k` pair there are 2 fourier
  terms sin_sp_k and cos_sp_k:
      - sin_sp_k = :math:`sin(\frac{2 \pi k t}{sp})`
      - cos_sp_k = :math:`cos(\frac{2 \pi k t}{sp})`
  
  Where :math:`t` is the elapsed time since the beginning of the seasonal period and
  :math:`sp` the total time of the seasonal period.
  
  The transformed output is a pandas DataFrame that includes the fourier terms as
  additional columns with the naming convention stated above (sin_sp_k and cos_sp_k).
  The numbers of Fourier terms :math:`K` in the fourier_terms_list
  determines the number of Fourier terms that will be used for each seasonal period,
  i.e., Fourier terms :math:`k = 1\dots K` (integers), cos and sine, will be generated
  for the seasonality :math:`sp` at the same list index.
  For example, consider sp_list = [12, "Y"] and fourier_terms_list = [2, 1].
  This says that we compute 2 (2 cos, 2 sine) Fourier terms for
  seasonality 12 periods, and 1 Fourier term (1 cos and 1 sine)
  for seasonality 1 year.
  The transformed series will then have columns with the following names:
  "cos_12_1", "sin_12_1", "cos_12_2", "sin_12_2", "cos_Y_1", "sin_Y_1"
  
  The implementation is based on the fourier function from the R forecast package [3]_
  
  Parameters
  ----------
  sp_list : List[float and/or str]
      List of seasonal periods. Can be defined with the following options:
      * float : Periodicity defined as number of timesteps since the beginning of the
      data seen in `fit`.
      * string : Periodicity defined as a column name in X that contains the
      :math:`t/sp` values
      * string : Periodicity defined as a pandas period alias:
      https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#period-aliases
  fourier_terms_list : List[int]
      List of number of fourier terms (:math:`K`) per corresponding (:math:`sp`); each
      :math:`K` matches to one :math:`sp` of the sp_list. For example, if sp_list =
      [7, "Y"] and fourier_terms_list = [3, 9], the seasonality of 7 timesteps will
      have 3 sin_sp_k and 3 cos_sp_k fourier terms and the yearly seasonality "Y" will
      have 9 sin_sp_k and 9 cos_sp_k fourier terms.
  freq : str, optional, default = None
      Only used when X has a pd.DatetimeIndex without a specified frequency.
      Specifies the frequency of the index of your data. The string should
      match a pandas offset alias:
      https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases
  keep_original_columns : boolean, optional, default=False
      Keep original columns in X passed to `.transform()`
  
  References
  ----------
  .. [1] Hyndsight - Forecasting with long seasonal periods:
      https://robjhyndman.com/hyndsight/longseasonality/
  .. [2] Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and
      practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3.
      Accessed on August 14th 2022.
  .. [3] https://pkg.robjhyndman.com/forecast/reference/fourier.html
  
  Examples
  --------
  >>> from sktime.transformations.series.fourier import FourierFeatures
  >>> from sktime.datasets import load_airline
  >>> y = load_airline()
  >>> transformer = FourierFeatures(sp_list=[12, "Y"], fourier_terms_list=[4, 1])
  >>> y_hat = transformer.fit_transform(y)
class_docstr_tok: ["Fourier","Features","for","time","series","seasonality",".","Fourier","Series","terms","can","be","used","as","explanatory","variables","for","the","cases","of","multiple","seasonal","periods","and","or","complex","\/","long","seasonal","periods","[","1","]","_",",","[","2","]","_",".","For","every","seasonal","period",",",":","math",":","`","sp","`","and","fourier","term",":","math",":","`","k","`","pair","there","are","2","fourier","terms","sin_sp_k","and","cos_sp_k",":","-","sin_sp_k","=",":","math",":","`","sin","(","\\frac","{","2","\\pi","k","t","}","{","sp","}",")","`","-","cos_sp_k","=",":","math",":","`","cos","(","\\frac","{","2","\\pi","k","t","}","{","sp","}",")","`","Where",":","math",":","`","t","`","is","the","elapsed","time","since","the","beginning","of","the","seasonal","period","and",":","math",":","`","sp","`","the","total","time","of","the","seasonal","period",".","The","transformed","output","is","a","pandas","DataFrame","that","includes","the","fourier","terms","as","additional","columns","with","the","naming","convention","stated","above","(","sin_sp_k","and","cos_sp_k",")",".","The","numbers","of","Fourier","terms",":","math",":","`","K","`","in","the","fourier_terms_list","determines","the","number","of","Fourier","terms","that","will","be","used","for","each","seasonal","period",",","i.e.",",","Fourier","terms",":","math",":","`","k","=","1\\dots","K","`","(","integers",")",",","cos","and","sine",",","will","be","generated","for","the","seasonality",":","math",":","`","sp","`","at","the","same","list","index",".","For","example",",","consider","sp_list","=","[","12",",","``","Y","''","]","and","fourier_terms_list","=","[","2",",","1","]",".","This","says","that","we","compute","2","(","2","cos",",","2","sine",")","Fourier","terms","for","seasonality","12","periods",",","and","1","Fourier","term","(","1","cos","and","1","sine",")","for","seasonality","1","year",".","The","transformed","series","will","then","have","columns","with","the","following","names",":","''","cos_12_1","''",",","``","sin_12_1","''",",","``","cos_12_2","''",",","``","sin_12_2","''",",","``","cos_Y_1","''",",","``","sin_Y_1","''","The","implementation","is","based","on","the","fourier","function","from","the","R","forecast","package","[","3","]","_","Parameters","--","--","--","--","--","sp_list",":","List","[","float","and\/or","str","]","List","of","seasonal","periods",".","Can","be","defined","with","the","following","options",":","*","float",":","Periodicity","defined","as","number","of","timesteps","since","the","beginning","of","the","data","seen","in","`","fit","`",".","*","string",":","Periodicity","defined","as","a","column","name","in","X","that","contains","the",":","math",":","`","t\/sp","`","values","*","string",":","Periodicity","defined","as","a","pandas","period","alias",":","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","period-aliases","fourier_terms_list",":","List","[","int","]","List","of","number","of","fourier","terms","(",":","math",":","`","K","`",")","per","corresponding","(",":","math",":","`","sp","`",")",";","each",":","math",":","`","K","`","matches","to","one",":","math",":","`","sp","`","of","the","sp_list",".","For","example",",","if","sp_list","=","[","7",",","``","Y","''","]","and","fourier_terms_list","=","[","3",",","9","]",",","the","seasonality","of","7","timesteps","will","have","3","sin_sp_k","and","3","cos_sp_k","fourier","terms","and","the","yearly","seasonality","``","Y","''","will","have","9","sin_sp_k","and","9","cos_sp_k","fourier","terms",".","freq",":","str",",","optional",",","default","=","None","Only","used","when","X","has","a","pd.DatetimeIndex","without","a","specified","frequency",".","Specifies","the","frequency","of","the","index","of","your","data",".","The","string","should","match","a","pandas","offset","alias",":","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","offset-aliases","keep_original_columns",":","boolean",",","optional",",","default=False","Keep","original","columns","in","X","passed","to","`",".transform","(",")","`","References","--","--","--","--","--","..","[","1","]","Hyndsight","-","Forecasting","with","long","seasonal","periods",":","https",":","\/\/robjhyndman.com\/hyndsight\/longseasonality\/","..","[","2","]","Hyndman",",","R.J.",",","&","Athanasopoulos",",","G.","(","2021",")","Forecasting",":","principles","and","practice",",","3rd","edition",",","OTexts",":","Melbourne",",","Australia",".","OTexts.com\/fpp3",".","Accessed","on","August","14th","2022",".","..","[","3","]","https",":","\/\/pkg.robjhyndman.com\/forecast\/reference\/fourier.html","Examples","--","--","--","--",">",">",">","from","sktime.transformations.series.fourier","import","FourierFeatures",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","y","=","load_airline","(",")",">",">",">","transformer","=","FourierFeatures","(","sp_list=","[","12",",","``","Y","''","]",",","fourier_terms_list=","[","4",",","1","]",")",">",">",">","y_hat","=","transformer.fit_transform","(","y",")"]
docstr: Transform X and return a transformed version.
  
  private _transform containing core logic, called from transform
  
  Parameters
  ----------
  X : Series or Panel of mtype X_inner_mtype
      if X_inner_mtype is list, _transform must support all types in it
      Data to be transformed
  y : Series or Panel of mtype y_inner_mtype, default=None
      Additional data, e.g., labels for transformation
  
  Returns
  -------
  transformed version of X
docstr_tok: ["Transform","X","and","return","a","transformed","version",".","private","_transform","containing","core","logic",",","called","from","transform","Parameters","--","--","--","--","--","X",":","Series","or","Panel","of","mtype","X_inner_mtype","if","X_inner_mtype","is","list",",","_transform","must","support","all","types","in","it","Data","to","be","transformed","y",":","Series","or","Panel","of","mtype","y_inner_mtype",",","default=None","Additional","data",",","e.g.",",","labels","for","transformation","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 : Series or Panel of mtype X_inner_mtype
          if X_inner_mtype is list, _transform must support all types in it
          Data to be transformed
      y : Series or Panel of mtype y_inner_mtype, default=None
          Additional data, e.g., labels for transformation
  
      Returns
      -------
      transformed version of X
      """
      X_transformed = pd.DataFrame(index=X.index)
      X_df = pd.DataFrame(X)
  
      if isinstance(X.index, pd.DatetimeIndex):
          time_index = X.index.to_period(self.freq_)
      else:
          time_index = X.index
  
      # get the integer form of the PeriodIndex
      int_index = time_index.astype("int64") - self.min_t_
  
      for sp_k in self.sp_k_pairs_list_:
          sp = sp_k[0]
          k = sp_k[1]
  
          if not isinstance(
              sp, str
          ):  # periodicity sp relative to start
              X_transformed[f"sin_{sp}_{k}"] = np.sin(
                  int_index * 2 * k * np.pi / sp
              )
              X_transformed[f"cos_{sp}_{k}"] = np.cos(
                  int_index * 2 * k * np.pi / sp
              )
  
          elif sp in X_df.columns:  # periodicity sp from X column
              frac_index = X_df[sp].values
              X_transformed[f"sin_{sp}_{k}"] = np.sin(
                  frac_index * 2 * k * np.pi
              )
              X_transformed[f"cos_{sp}_{k}"] = np.cos(
                  frac_index * 2 * k * np.pi
              )
  
          else:  # periodicity sp from offset string
              if isinstance(X.index, pd.PeriodIndex):
                  datetime_index = X.index.to_timestamp()
              else:
                  datetime_index = X.index
  
              frac_index = self._offset_frac_since_prev_offset(
                  datetime_index=datetime_index,
                  period_str=sp,
              )
              X_transformed[f"sin_{sp}_{k}"] = np.sin(
                  frac_index * 2 * k * np.pi
              )
              X_transformed[f"cos_{sp}_{k}"] = np.cos(
                  frac_index * 2 * k * np.pi
              )
  
      if self.keep_original_columns:
          X_transformed = pd.concat(
              [X, X_transformed], axis=1, copy=True
          )
  
      return X_transformed
  
file_path: sktime/sktime/transformations/series/fourier.py
imports: import warnings
  from typing import List, Optional
  import numpy
  import pandas
  from numpy.fft import rfft
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 3 for calling the FourierFeatures obj's underlying member method code with example usage: obj._transform(X, y) and returns: X_transformed