create_hsgp_from_config#
- pymc_marketing.mmm.tvp.create_hsgp_from_config(X, dims, config, X_mid=None)[source]#
Create a SoftPlusHSGP instance from either HSGPKwargs or dict config.
This function provides a unified interface for creating SoftPlusHSGP instances, supporting both the legacy HSGPKwargs format and the newer parameterize_from_data format.
- Parameters:
- X
pt.TensorVariable|npt.NDArray[np.floating[Any]] Time index or input data for the HSGP.
- dims
Dims Dimensions for the HSGP variable (e.g.,
("date",)or("date", "channel")).- config
HSGPKwargs|dict[str,Any] Configuration for the HSGP. Can be:
An
HSGPKwargsinstanceA dict with HSGPKwargs keys (
m,L,eta_lam,ls_mu,ls_sigma,cov_func)A dict with parameterize_from_data keys (
ls_lower,ls_upper, etc.)
- X_mid
int|float|None, optional Midpoint of the time index. If None, computed from X.
- X
- Returns:
SoftPlusHSGPConfigured SoftPlusHSGP instance ready for use.
- Raises:
TypeErrorIf config is neither HSGPKwargs, dict, nor a valid format.
See also
pymc_marketing.hsgp_kwargs.HSGPKwargsLegacy configuration format.
pymc_marketing.mmm.hsgp.SoftPlusHSGP.parameterize_from_dataNew configuration format.
Examples
Using HSGPKwargs instance:
>>> from pymc_marketing.hsgp_kwargs import HSGPKwargs >>> config = HSGPKwargs(m=200, eta_lam=1.0, ls_mu=5.0, ls_sigma=10.0) >>> hsgp = create_hsgp_from_config(X=np.arange(52), dims="date", config=config)
Using parameterize_from_data format dict:
>>> config = {"ls_lower": 0.3, "ls_upper": 2.0} >>> hsgp = create_hsgp_from_config(X=np.arange(52), dims="date", config=config)