0
from pmdarima.pipeline import Pipeline
from pmdarima.preprocessing import FourierFeaturizer

pipeline = Pipeline([
    ("fourier_1", FourierFeaturizer(m=7, k=1)),
    ("fourier_2", FourierFeaturizer(m=14, k=1)),
])

pipeline.fit_transform(df['value'])

When I run above code. I get following error: TypeError: Last step of Pipeline should be of type BaseARIMA. 'FourierFeaturizer(k=1, m=14)'

I don't wish to use BaseARIMA. Just wish to use FourierFeaturizer is it possible?

Anant
  • 206
  • 2
  • 8
  • BTW, the docs say this about the maximum value of k: `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.`. Don't know that it's the problem, but watch out for that. – Nick ODell Jul 26 '22 at 18:40
  • 1
    I get the same error even if I change k to 1. – Anant Jul 26 '22 at 18:42

1 Answers1

0

Yes, it's possible.

Each FourierFeaturizer has a fit_transform method, which returns the y var and new exogenous variables. By concatenating this return value, you get Fourier features.

y, x1 = FourierFeaturizer(m=7, k=2).fit_transform(df[['value']])
y, x2 = FourierFeaturizer(m=365, k=2).fit_transform(y)
exog = pd.concat([x1, x2], axis=1)

Warning: If you use m values which are multiples of each other, you will get co-linearity, because the 2nd frequency of m=14 is exactly the same as the 1st frequency of m=7. When using multiple seasonality, make sure their periods are not multiples of each other.

Nick ODell
  • 15,465
  • 3
  • 32
  • 66
  • Should you pass x1 as covariate in the second fit_transform call? like: fit_transform(y, X=x1) ? (https://github.com/alkaline-ml/pmdarima/blob/cafd5c79/pmdarima/preprocessing/base.py#L42) – Anant Jul 27 '22 at 03:58
  • @Anant You could, but I don't see why you'd need to. The second featurizer doesn't rely on the first featurizer's ouptut. – Nick ODell Jul 27 '22 at 05:19