class_docstr: Fourier terms for modeling seasonality
  
  This transformer creates an exogenous matrix containing terms from a
  Fourier series, up to order ``k``. It is based on ``R::forecast code`` [1].
  In practice, it permits us to fit a seasonal time series *without* seasonal
  order (i.e., ``seasonal=False``) by supplying decomposed seasonal Fourier
  terms as an exogenous array.
  
  The advantages of this technique, per Hyndman [2]:
  
      * It allows any length seasonality
      * The seasonal pattern is smooth for small values of K (but more wiggly
        seasonality can be handled by increasing K)
      * The short-term dynamics are easily handled with a simple ARMA error
  
  The disadvantage is that the seasonal periodicity of the time series is
  assumed to be fixed.
  
  Functionally, this is a featurizer. This means that exogenous features are
  *derived* from ``y``, as opposed to transforming an existing exog array.
  It also behaves slightly differently in the :func:`transform` stage than
  most other exogenous transformers in that ``exog`` is not a required arg,
  and it takes ``**kwargs``. See the :func:`transform` docstr for more info.
  
  Parameters
  ----------
  m : int
      The seasonal periodicity of the endogenous vector, y.
  
  k : int, optional (default=None)
      The number of sine and cosine terms (each) to include. I.e., if ``k``
      is 2, 4 new features will be generated. ``k`` must not exceed ``m/2``,
      which is the default value if not set. The value of ``k`` can be
      selected by minimizing the AIC.
  
  prefix : str or None, optional (default=None)
      The feature prefix
  
  Examples
  --------
  >>> import pandas as pd
  >>> from pmdarima.preprocessing import FourierFeaturizer
  >>> from pmdarima.datasets import load_wineind
  >>> y = load_wineind()
  >>> trans = FourierFeaturizer(12, 4)
  >>> y_prime, X = trans.fit_transform(y)
  >>> X.head()
     FOURIER_S12-0     FOURIER_C12-0    ...     FOURIER_S12-3  FOURIER_C12-3
  0       0.500000      8.660254e-01    ...      8.660254e-01           -0.5
  1       0.866025      5.000000e-01    ...     -8.660255e-01           -0.5
  2       1.000000     -4.371139e-08    ...      1.748456e-07            1.0
  3       0.866025     -5.000001e-01    ...      8.660253e-01           -0.5
  4       0.500000     -8.660254e-01    ...     -8.660255e-01           -0.5
  
  Notes
  -----
  * Helpful for long seasonal periods (large ``m``) where ``seasonal=True``
    seems to take a very long time to fit a model.
  
  References
  ----------
  .. [1] https://github.com/robjhyndman/forecast/blob/master/R/season.R
  .. [2] https://robjhyndman.com/hyndsight/longseasonality/
class_docstr_tok: ["Fourier","terms","for","modeling","seasonality","This","transformer","creates","an","exogenous","matrix","containing","terms","from","a","Fourier","series",",","up","to","order","``","k","``",".","It","is","based","on","``","R",":",":forecast","code","``","[","1","]",".","In","practice",",","it","permits","us","to","fit","a","seasonal","time","series","*","without","*","seasonal","order","(","i.e.",",","``","seasonal=False","``",")","by","supplying","decomposed","seasonal","Fourier","terms","as","an","exogenous","array",".","The","advantages","of","this","technique",",","per","Hyndman","[","2","]",":","*","It","allows","any","length","seasonality","*","The","seasonal","pattern","is","smooth","for","small","values","of","K","(","but","more","wiggly","seasonality","can","be","handled","by","increasing","K",")","*","The","short-term","dynamics","are","easily","handled","with","a","simple","ARMA","error","The","disadvantage","is","that","the","seasonal","periodicity","of","the","time","series","is","assumed","to","be","fixed",".","Functionally",",","this","is","a","featurizer",".","This","means","that","exogenous","features","are","*","derived","*","from","``","y","``",",","as","opposed","to","transforming","an","existing","exog","array",".","It","also","behaves","slightly","differently","in","the",":","func",":","`","transform","`","stage","than","most","other","exogenous","transformers","in","that","``","exog","``","is","not","a","required","arg",",","and","it","takes","``","*","*","kwargs","``",".","See","the",":","func",":","`","transform","`","docstr","for","more","info",".","Parameters","--","--","--","--","--","m",":","int","The","seasonal","periodicity","of","the","endogenous","vector",",","y.","k",":","int",",","optional","(","default=None",")","The","number","of","sine","and","cosine","terms","(","each",")","to","include",".","I.e.",",","if","``","k","``","is","2",",","4","new","features","will","be","generated",".","``","k","``","must","not","exceed","``","m\/2","``",",","which","is","the","default","value","if","not","set",".","The","value","of","``","k","``","can","be","selected","by","minimizing","the","AIC",".","prefix",":","str","or","None",",","optional","(","default=None",")","The","feature","prefix","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","from","pmdarima.preprocessing","import","FourierFeaturizer",">",">",">","from","pmdarima.datasets","import","load_wineind",">",">",">","y","=","load_wineind","(",")",">",">",">","trans","=","FourierFeaturizer","(","12",",","4",")",">",">",">","y_prime",",","X","=","trans.fit_transform","(","y",")",">",">",">","X.head","(",")","FOURIER_S12-0","FOURIER_C12-0","...","FOURIER_S12-3","FOURIER_C12-3","0","0.500000","8.660254e-01","...","8.660254e-01","-0.5","1","0.866025","5.000000e-01","...","-8.660255e-01","-0.5","2","1.000000","-4.371139e-08","...","1.748456e-07","1.0","3","0.866025","-5.000001e-01","...","8.660253e-01","-0.5","4","0.500000","-8.660254e-01","...","-8.660255e-01","-0.5","Notes","--","--","-","*","Helpful","for","long","seasonal","periods","(","large","``","m","``",")","where","``","seasonal=True","``","seems","to","take","a","very","long","time","to","fit","a","model",".","References","--","--","--","--","--","..","[","1","]","https",":","\/\/github.com\/robjhyndman\/forecast\/blob\/master\/R\/season.R","..","[","2","]","https",":","\/\/robjhyndman.com\/hyndsight\/longseasonality\/"]
docstr: Create Fourier term features
  
  When an ARIMA is fit with an exogenous array, it must be forecasted
  with one also. Since at ``predict`` time in a pipeline we won't have
  ``y`` (and we may not yet have an ``exog`` array), we have to know how
  far into the future for which to compute Fourier terms (hence
  ``n_periods``).
  
  This method will compute the Fourier features for a given frequency and
  ``k`` term. Note that the ``y`` values are not used to compute these,
  so this does not pose a risk of data leakage.
  
  Parameters
  ----------
  y : array-like or None, shape=(n_samples,)
      The endogenous (time-series) array. This is unused and technically
      optional for the Fourier terms, since it uses the pre-computed
      ``n`` to calculate the seasonal Fourier terms.
  
  X : array-like or None, shape=(n_samples, n_features), optional
      The exogenous array of additional covariates. If specified, the
      Fourier terms will be column-bound on the right side of the matrix.
      Otherwise, the Fourier terms will be returned as the new exogenous
      array.
  
  n_periods : int, optional (default=0)
      The number of periods in the future to forecast. If ``n_periods``
      is 0, will compute the Fourier features for the training set.
      ``n_periods`` corresponds to the number of samples that will be
      returned.
docstr_tok: ["Create","Fourier","term","features","When","an","ARIMA","is","fit","with","an","exogenous","array",",","it","must","be","forecasted","with","one","also",".","Since","at","``","predict","``","time","in","a","pipeline","we","wo","n't","have","``","y","``","(","and","we","may","not","yet","have","an","``","exog","``","array",")",",","we","have","to","know","how","far","into","the","future","for","which","to","compute","Fourier","terms","(","hence","``","n_periods","``",")",".","This","method","will","compute","the","Fourier","features","for","a","given","frequency","and","``","k","``","term",".","Note","that","the","``","y","``","values","are","not","used","to","compute","these",",","so","this","does","not","pose","a","risk","of","data","leakage",".","Parameters","--","--","--","--","--","y",":","array-like","or","None",",","shape=","(","n_samples",",",")","The","endogenous","(","time-series",")","array",".","This","is","unused","and","technically","optional","for","the","Fourier","terms",",","since","it","uses","the","pre-computed","``","n","``","to","calculate","the","seasonal","Fourier","terms",".","X",":","array-like","or","None",",","shape=","(","n_samples",",","n_features",")",",","optional","The","exogenous","array","of","additional","covariates",".","If","specified",",","the","Fourier","terms","will","be","column-bound","on","the","right","side","of","the","matrix",".","Otherwise",",","the","Fourier","terms","will","be","returned","as","the","new","exogenous","array",".","n_periods",":","int",",","optional","(","default=0",")","The","number","of","periods","in","the","future","to","forecast",".","If","``","n_periods","``","is","0",",","will","compute","the","Fourier","features","for","the","training","set",".","``","n_periods","``","corresponds","to","the","number","of","samples","that","will","be","returned","."]
code: def transform(self, y, X=None, n_periods=0, **kwargs):
      """Create Fourier term features
  
      When an ARIMA is fit with an exogenous array, it must be forecasted
      with one also. Since at ``predict`` time in a pipeline we won't have
      ``y`` (and we may not yet have an ``exog`` array), we have to know how
      far into the future for which to compute Fourier terms (hence
      ``n_periods``).
  
      This method will compute the Fourier features for a given frequency and
      ``k`` term. Note that the ``y`` values are not used to compute these,
      so this does not pose a risk of data leakage.
  
      Parameters
      ----------
      y : array-like or None, shape=(n_samples,)
          The endogenous (time-series) array. This is unused and technically
          optional for the Fourier terms, since it uses the pre-computed
          ``n`` to calculate the seasonal Fourier terms.
  
      X : array-like or None, shape=(n_samples, n_features), optional
          The exogenous array of additional covariates. If specified, the
          Fourier terms will be column-bound on the right side of the matrix.
          Otherwise, the Fourier terms will be returned as the new exogenous
          array.
  
      n_periods : int, optional (default=0)
          The number of periods in the future to forecast. If ``n_periods``
          is 0, will compute the Fourier features for the training set.
          ``n_periods`` corresponds to the number of samples that will be
          returned.
      """
      check_is_fitted(self, "p_")
      _, X = self._check_y_X(y, X, null_allowed=True)
  
      if n_periods and X is not None:
          if n_periods != X.shape[0]:
              raise ValueError(
                  f"If n_periods and X are specified, n_periods must match "
                  f"dims of X ({n_periods} != {X.shape[0]})"
              )
  
      times = np.arange(self.n_ + n_periods, dtype=np.float64) + 1
      X_fourier = _fourier_terms(self.p_, times)  # type: np.ndarray
  
      # Maybe trim if we're in predict mode... in that case, we only keep the
      # last n_periods rows in the matrix we've created
      if n_periods:
          X_fourier = X_fourier[-n_periods:, :]
  
      X = self._safe_hstack(X, X_fourier)
      return y, X
  
file_path: pmdarima/pmdarima/preprocessing/exog/fourier.py
imports: import numpy
  from .base import BaseExogFeaturizer
  from ..base import UpdatableMixin
  from ...compat import check_is_fitted
  from ._fourier import C_fourier_terms
label_desc: Use image node_id 5 for calling the FourierFeaturizer obj's underlying member method code with example usage: obj.transform(y, X, n_periods) and returns: y,  X