create_dim_handler#
- pymc_marketing.model_config.create_dim_handler(desired_dims)[source]#
Create a function that maps variable shapes to the desired dims.
- Parameters:
Examples
Map variable to “channel” dim:
import numpy as np from pymc_marketing.model_config import create_dim_handler handle_channel = create_dim_handler("channel") handle_channel(np.array([1, 2, 3]), "channel")
Map variable to “channel” and “geo” dims:
import numpy as np from pymc_marketing.model_config import create_dim_handler handle_channel_geo = create_dim_handler(("channel", "geo")) # Transpose the array to match the desired dims handle_channel_geo(np.array([[1, 2, 3], [4, 5, 6]]), ("geo", "channel")) # Add a new axis to the array to match the desired dims handle_channel_geo(np.array([1, 2, 3]), "channel")