Skip to content

Fix BudgetOptimizer docstrings #1705

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TeemuSailynoja
Copy link
Contributor

@TeemuSailynoja TeemuSailynoja commented May 23, 2025

Description

Related Issue

Checklist


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

@github-actions github-actions bot added MMM docs Improvements or additions to documentation optimizer labels May 23, 2025
Comment on lines +120 to +121
budgets_to_optimize : xarray.DataArray, optional
Mask defining a subset of budgets to optimize. Non-optimized budgets remain fixed at 0.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This perhaps would need an example to specify the required shape for the mask.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look here:

import numpy as np
import pandas as pd
import xarray as xr

# Create simulated data with only date and channel dimensions
channels = ['TV', 'Radio', 'Social', 'Display', 'Search']  # All available channels
dates = pd.date_range('2023-01-01', periods=10, freq='W')

# Create sample channel_data (shape: date, channel)
channel_data = xr.DataArray(
    np.random.rand(len(dates), len(channels)),
    coords={
        'date': dates,
        'channel': channels  
    },
    dims=['date', 'channel']
)

# Select which channels to optimize
channels_to_optimize = ['TV', 'Search']  # Only optimize these 2 channels

# Create the budget mask (removing date dimension)
# First, take the max across dates to get a template with only channel dimension
channel_template = channel_data.max('date')  # Shape: (channel)

# Create boolean mask - True only for channels we want to optimize
budgets_to_optimize = xr.DataArray(
    [ch in channels_to_optimize for ch in channels],
    coords={'channel': channels},
    dims=['channel']
)

print("Channel data shape:", channel_data.shape)
print("Budgets to optimize mask:")
print(budgets_to_optimize)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TeemuSailynoja Are you planning to add the example? if so, we can merge after otherwise, we can just add an issue and merge this one!

Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.59%. Comparing base (4c4f251) to head (8610b46).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1705   +/-   ##
=======================================
  Coverage   91.59%   91.59%           
=======================================
  Files          60       60           
  Lines        6778     6778           
=======================================
  Hits         6208     6208           
  Misses        570      570           

☔ 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.

@williambdean williambdean requested a review from cetagostini May 23, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation MMM optimizer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong BudgetOptimizer docstring
3 participants