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

Missing Method: get_paid_media_channels_argument_builder() Not Found in meridian.input_data #544

Open
HoussemBouazizi opened this issue Feb 28, 2025 · 2 comments

Comments

@HoussemBouazizi
Copy link

🔍 Issue Summary

The function get_paid_media_channels_argument_builder() is referenced in the Meridian documentation, but it does not exist in meridian.input_data. This causes an AttributeError when trying to call it as shown in the official documentation. Additionally, when attempting to use the InputData class as a workaround, it forces a geographic hierarchy model, which is not suitable for my use case as I am working on a national model without a geo dimension.

📌 Expected Behavior

  • The method meridian.input_data.get_paid_media_channels_argument_builder() should exist and return an argument builder for paid media channels.
  • National models should have a way to access this method without requiring InputData and geographic dimensions.

🐛 Observed Behavior

Calling:

build_media_channel_args = meridian.input_data.get_paid_media_channels_argument_builder()

Results in the error:

AttributeError: module 'meridian.input_data' has no attribute 'get_paid_media_channels_argument_builder'

Attempting to use the InputData class to access the method forces me to provide geo, which does not apply to my national model setup.

🔗 References

🙏 Request

Could you confirm whether get_paid_media_channels_argument_builder() is supposed to work without requiring InputData, or if an alternative exists for national models that do not include a geo dimension? If this is a bug, please clarify how national models should handle media channel arguments. Thanks for your help! 🙌

@santoso-wijaya
Copy link
Member

santoso-wijaya commented Feb 28, 2025

Hi,

We updated the documentation in tandem with commit 4521db1 that we pushed yesterday.

However, it has not been published to PyPI yet. If you had installed Meridian with pip install google-meridian, it will pull the latest Meridian package (v.1.0.3) without this recent change.

Some workarounds:

  • You can access get_paid_media_channels_argument_builder() if you installed Meridian directly from GitHub at HEAD commit with pip install --upgrade git+https://github.com/google/meridian.git
  • Pass arrays directly to the parameters that expect channel-indexed values without the facilitation of get_paid_media_channels_argument_builder(). get_paid_media_channels_argument_builder() makes this easier, but you can still pass the optimizer naked arrays (take care of channel ordering, though).
  • Wait until we publish v1.0.4 to PyPI later today with these changes included.

I'm not sure what you meant by using "InputData class as a workaround, it forces a geographic hierarchy model, which is not suitable for my use case as I am working on a national model without a geo dimension." You should be able to create an InputData whose data array constituents do not include a geo dimension--effectively making it a national model. Can you share an example stack trace that you came upon?

@santoso-wijaya
Copy link
Member

Could you confirm whether get_paid_media_channels_argument_builder() is supposed to work without requiring InputData

You can bypass the requirement of InputData by creating the argument builder directly:

from meridian.data import arg_builder

build_media_channel_args = arg_builder.OrderedListArgumentBuilder([
    'Channel1',
    'Channel2',
    'Channel3',
    'Channel4',
    'Channel5',
    'Channel6'
])

# The rest is the same as the code snippet in https://developers.devsite.corp.google.com/meridian/docs/user-guide/configure-model

my_input_data.get_paid_media_channels_argument_builder() just facilitates the seeding of the argument builder with your media channel names.

However, this also requires the latest Meridian code at HEAD. If you're still working with [email protected] or earlier, you will have to create, for instance, roi_m_mu and roi_m_sigma manually. For example:

roi_m_mu    = [0.2, 0.3, 0.4, 0.3, 0.3, 0.4]  # must match media channel ordering in InputData
roi_m_sigma = [0.7, 0.9, 0.6, 0.7, 0.6, 0.5]  # must match media channel ordering in InputData

prior = prior_distribution.PriorDistribution(
    roi_m=tfp.distributions.LogNormal(
        roi_m_mu, roi_m_sigma, name=constants.ROI_M
    )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants