MMMPlotConfig#
- class pymc_marketing.mmm.config.MMMPlotConfig[source]#
Configuration dictionary for MMM plotting settings.
Global configuration object that controls MMM plotting behavior including backend selection and version control. Modeled after ArviZ’s rcParams pattern.
See also
MMM.plotProperty that returns appropriate plot suite based on config
MMMPlotSuiteNew multi-backend plotting suite
LegacyMMMPlotSuiteLegacy matplotlib-only suite
Notes
Configuration changes affect all subsequent plot calls globally unless overridden at the method level using the
backendparameter.The configuration is a singleton - changes affect all MMM instances in the current Python session.
Examples
Set plotting backend globally:
from pymc_marketing.mmm import mmm_plot_config mmm_plot_config["plot.backend"] = "plotly" # All plots now use plotly by default mmm = MMM(...) mmm.fit(X, y) pc = mmm.plot.posterior_predictive() # Uses plotly pc.show()
Enable new plotting suite (v2):
mmm_plot_config["plot.use_v2"] = True # Now using arviz_plots-based multi-backend suite mmm = MMM(...) mmm.fit(X, y) pc = mmm.plot.contributions_over_time(var=["intercept"]) pc.show()
Suppress warnings:
mmm_plot_config["plot.show_warnings"] = False
Reset to defaults:
mmm_plot_config.reset() mmm_plot_config["plot.backend"] # 'matplotlib'
Context manager pattern for temporary config changes:
original = mmm_plot_config["plot.backend"] try: mmm_plot_config["plot.backend"] = "plotly" # Use plotly for this section pc = mmm.plot.posterior_predictive() pc.show() finally: mmm_plot_config["plot.backend"] = original
Methods
MMMPlotConfig.fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
MMMPlotConfig.get(key[, default])Return the value for key if key is in the dictionary, else default.
MMMPlotConfig.pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
Remove and return a (key, value) pair as a 2-tuple.
Reset all configuration to default values.
MMMPlotConfig.setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
MMMPlotConfig.update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
Attributes
VALID_KEYS