Model Understanding >

Fourier Transform

It is often said that bitcoin has a cycle like its price goes up and down at some intervals. We verify if that is really the case using fourier transform.

Fourier transform is a technique to decompose a signal into its constituent frequencies where frequency refers to the number of cycles in a given time period.

Can you identify cycles from the below?

First component in the data is $sin(2 \pi t)$ which has period of 1 which corresponds to frequency of 1 (= 1/1).

Second is $cos(2 \pi * {t \over 10})$ which has period of 10 which corresponds to frequency of 0.1 (= 1/10).

And the sum of those two, $sin(2 \pi t) + cos(2 \pi * {t \over 10})$, is the original data. Fourier transform is a tool to identify such frequencies.

Fourier Transform of Air Passenger Data

To demonstrate model performance, we show the model's prediction results for the air passengers dataset. The cross validation process identified the best transformation to make the time series stationary and the optimal hyperparameters. The Root Mean Squared Error on the next day's closing price was used to determine the best model.

In the chart, we display the model's predictions for last split of cross validation and test data.

  1. train: Training data of the last split.
  2. validation: Validation data of the last split.
  3. prediction (train, validation): Prdiction for train and validation data period. For each row (or a sliding window) of data, predictions are made for n days into the future (where n is set to 1, 2, 7). The predictions are then combined into a single series of dots. Since the accuracy of predictions decreases for large n, we see some hiccups in the predictions. The predictions from the tail of the train spills into the validation period as that's future from the 'train' data period viewpoint. These are somewhat peculiar settings, but it works well in testing if the model's predictions are good enough.
  4. test(input): Test input data.
  5. test(actual): Test actual data.
  6. prediction(test): The model's prediction given the test input. There's only one prediction from the last row (or the last sliding window) of the test input which corresponds to 1, 2, 7 days later after 'test(input)'.

While fourier transform is useful in identifying cycles, air passengers data doesn't exhibit perfect cycles. Small changes in its regularity makes the generalization challenging.