title: Can somebody explain how to model seasonality in timeseries, via Fast Fourier Transform, FFT?
body: <p>A series, yt, can be decomposed and modeled thus:</p>
  <p><code>yt = drift(or trend) + seasonality + noise</code>, which is in tandem with Parseval's theorem.</p>
  <p>One of the techniques used to model a series's seasonality is the application of the FFT algorithm. I have read few texts about it(FFT) and I understand what it does but how do I incorporate it back into the model, before modeling for noise?</p>
  <p>I suppose FFT transforms a signal into a linear combination of sine and cosine functions of frequencies that makes up the signal. How then do I incorporate it back into the model? I have read few examples I haven't understood properly, or should I say my curiosity isn't satisfied yet.</p>
  <p>For example, consider the series yt:</p>
  <pre><code>from sklearn.linear_model import LinearRegression
  from sklearn.preprocessing import PolynomialFeature
  from sklearn.pipeline import Pipeline, FeatureUnion
  from sklearn.model_selection import train_test_split
  
  
  # data
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
  
  # estimators
  linear_model = LinearRegression()
  poly_feat = PolynomialFeatures(degree=3)
  
  # modeling trend
  pipe = Pipeline([ ('poly_trans', poly_feat), ('regressor', linear_model) ])
  pipe.fit(X_train, y_train).score(X_test, y_test) # 0.76
  </code></pre>
  <p>Now suppose I am to model the seasonality in this series, where I get employ FFT, I think I would attempt to use a FeatureUnion to combine the trend and seasonal effect thus:</p>
  <pre><code>from scipy.fftpack import fft
  
  poly_fft_union = FeatureUnion([ ('poly_trans', poly_feat), ('fft', fft) ])
  </code></pre>
  <p>This is where I am stuck. fft transformation returns complex numbers. I do not want to share more information because I don't want folks around to make assumptions that I know some aspects of this. Examples I have studied online either avoided using the fft or wrote a custom Estimator that applied the sin/cosine Fourier transformation formula directly.</p>
  <p>If I weren't stuck, then I would model the trend and seasonality thus</p>
  <pre><code>pipe = Pipeline([ ('union', poly_fft_union), ('regressor', linear_model)
  pipe.fit(X_train, y_train)
  </code></pre>
  <p>I need to feed my curiosity here. Please, anyone?!</p>