Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fourier seasonality transformations #1442

Open
PabloRoque opened this issue Jan 28, 2025 · 3 comments
Open

Fourier seasonality transformations #1442

PabloRoque opened this issue Jan 28, 2025 · 3 comments
Labels
enhancement New feature or request MMM model components Related to the various model components

Comments

@PabloRoque
Copy link
Contributor

Currently we have YearlyFourier and MonthlyFourier as subclasses of FourierBase.

It would be nice to include WeeklyFourier (and perhaps DailyFourier) for datasets with finer time granularity.

Additionally, BaseMMM only makes use of yearly_seasonality. Maybe we could replace in favor of a seasonalities: List[FourierBase]

Also FourierBase.apply contains: periods = dayofyear / self.days_in_period. Perhaps we should make dayofyear a more general param

@wd60622
Copy link
Contributor

wd60622 commented Jan 28, 2025

Hearing few things here

  • allowing passing fourier class(es) to MMM
  • support weekly and daily fourier classes

2 is easier than 1 and probs should come first. I am all for. That why they are easy to subclass

@PabloRoque PabloRoque mentioned this issue Jan 28, 2025
6 tasks
@wd60622 wd60622 added model components Related to the various model components and removed request discussion labels Jan 28, 2025
@PabloRoque
Copy link
Contributor Author

On allowing passing fourier class(es) to MMM.

We are currently passing yearly_seasonality : Optional[int] and then initializing as self.yearly_fourier = YearlyFourier(...).

We have 2 alternatives:

  1. Easiest would be to add 2 new params: monthly_seasonality:Optional[int], weekly_seasonality:Optional[int] and initialize equivalently to YearlyFourier. Then handle these in build_model
  2. Substitute yearly_seasonality param for a seasonalities:Optional[List[int]] | Optional[List[FourierBase]]. Then handle these in __init__ and build_model

Although 1 would add boilerplate code, I feel it might be easier for an end-user to understand how to use it.

What's your take?

@wd60622
Copy link
Contributor

wd60622 commented Jan 31, 2025

Good question. I think the easiest would be allow for a new parameter monthly_seasonality which would act like yearly_seasonality by taking an int or None.

I like the idea of taking a list, but what is the behavior when I pass more than one, say, YearlyFourier classes? Should that be allowed? Or [YearlyFourier(...), MonthlyFourier(...), MonthlyFourier(...)]

At the moment, we don't even have the ability to pass a custom Fourier class as the prior is defined in the model_config instead of with the class itself. So there is some complexity to add support there.

Think either can come first but mirroring the yearly_seasonality with monthly_seasonality parameter might be the easiest. We will have to be careful that the previous models are backward compat as the model_config is part of the comparison:

hasher.update(str(self.model_config.values()).encode())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MMM model components Related to the various model components
Projects
None yet
Development

No branches or pull requests

2 participants