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: Get time passed as fraction of the current period.
  
  Parameters
  ----------
  datetime_index : pandas DatetimeIndex
  period_str : pandas period str
      Cannot contain digits
  
  Returns
  -------
  numpy array containing the time passed between [previous offset, next offset)
  as fraction in the interval [0, 1) for every datetime in datetimes
docstr_tok: ["Get","time","passed","as","fraction","of","the","current","period",".","Parameters","--","--","--","--","--","datetime_index",":","pandas","DatetimeIndex","period_str",":","pandas","period","str","Can","not","contain","digits","Returns","--","--","--","-","numpy","array","containing","the","time","passed","between","[","previous","offset",",","next","offset",")","as","fraction","in","the","interval","[","0",",","1",")","for","every","datetime","in","datetimes"]
code: def _offset_frac_since_prev_offset(self, datetime_index, period_str):
      """Get time passed as fraction of the current period.
  
      Parameters
      ----------
      datetime_index : pandas DatetimeIndex
      period_str : pandas period str
          Cannot contain digits
  
      Returns
      -------
      numpy array containing the time passed between [previous offset, next offset)
      as fraction in the interval [0, 1) for every datetime in datetimes
      """
  
      def _get_frac(datetime, offset_boundaries):
          i = np.searchsorted(offset_boundaries, datetime, side="right")
          prev = offset_boundaries[i - 1]
          next = offset_boundaries[i]
          period_timedelta = next - prev
          since_prev_timedelta = datetime - prev
          return since_prev_timedelta / period_timedelta
  
      offset = pd.tseries.frequencies.to_offset(period_str)
      offset_boundaries = pd.date_range(
          start=np.amin(datetime_index) - offset,
          end=np.amax(datetime_index) + offset,
          freq=period_str,
          tz=datetime_index.tz,
      )
  
      # date_range created with offsets <= 1day have boundaries on the first
      # moment of the new period, but date_range created with offsets > 1day
      # have boundaries on the last day of the period rather than the desired
      # first day of new period. workaround: shift by 1 day
      offset_td = pd.to_timedelta(offset, errors="coerce")
      if not offset_td <= pd.Timedelta(days=1):
          offset_boundaries = offset_boundaries + pd.Timedelta(days=1)
  
      fracs = [
          _get_frac(dt, offset_boundaries) for dt in datetime_index
      ]
  
      return np.array(fracs)
  
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 4 for calling the FourierFeatures obj's underlying member method code with example usage: obj._offset_frac_since_prev_offset(datetime_index, period_str) and returns: np, unknown