Skip to content

Conversation

@williambdean
Copy link
Contributor

@williambdean williambdean commented Jan 24, 2025

Description

WIP but the API would look like this:

hsgp = SoftPlusHSGP.parameterize_from_data(
    np.arange(X.shape[0]),
    dims=("date", "channel"),
)

mmm = MMM(
    adstock=GeometricAdstock(l_max=8),
    saturation=LogisticSaturation(),
    date_column="date_week",
    channel_columns=["x1", "x2"],
    control_columns=[
        "event_1",
        "event_2",
        "t",
    ],
    time_varying_media=hsgp,
    yearly_seasonality=2,
)
mmm.fit(X, y)

Anything that follows the HSGPLike protocol can be used. This can be GPs or other time varying functions

@runtime_checkable
class HSGPLike(Protocol):
    """Quacks like a HSGP."""

    dims: tuple[str, ...]

    def create_variable(self, name: str) -> TensorVariable:
        """Create a variable."""

    def register_data(self, X: TensorLike) -> Self:
        """Register the data."""
        ...

CC: @cetagostini

Related Issue

  • Closes #
  • Related to #

Checklist


📚 Documentation preview 📚: https://pymc-marketing--1432.org.readthedocs.build/en/1432/

@williambdean williambdean linked an issue Jan 24, 2025 that may be closed by this pull request
@github-actions github-actions bot added MMM TVPs Related to time varying parameters enhancement New feature or request labels Jan 24, 2025
@codecov
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

❌ Patch coverage is 75.86207% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.40%. Comparing base (d9f0c51) to head (264ed2e).
⚠️ Report is 348 commits behind head on main.

Files with missing lines Patch % Lines
pymc_marketing/mmm/mmm.py 62.06% 11 Missing ⚠️
pymc_marketing/mmm/hsgp.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1432      +/-   ##
==========================================
- Coverage   94.62%   94.40%   -0.23%     
==========================================
  Files          50       50              
  Lines        5416     5448      +32     
==========================================
+ Hits         5125     5143      +18     
- Misses        291      305      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@juanitorduz
Copy link
Collaborator

cool!

@cetagostini
Copy link
Contributor

Like it will implement on #1036

@juanitorduz
Copy link
Collaborator

I like this API a lot!

@juanitorduz
Copy link
Collaborator

Hey @williambdean , it would be great to push this one. Do you need some support? What is missing :) ?

@williambdean
Copy link
Contributor Author

Just a bit of time to complete and some thoughts on how much we want to break the previous behavior as the configuration will likely change quite heavily

@williambdean
Copy link
Contributor Author

williambdean commented Jun 27, 2025

I will likely close this and restart with fresh eyes

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 TVPs Related to time varying parameters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for HSGP Component in MMM class

4 participants