Skip to main content

Python package for generating MMM (Marketing Mix Model) input data

Project description

logo

PySiMMMulator

CodeFactor PyPI Downloads

PySiMMMulator is an open source Python adaption of the R-package siMMMulator, which allows users to generate simulated data to use in testing Marketing Mix Models (MMMs). While this package cointains a full pipeline for data generation (configurable via .conf file) it can also be utilized in parts to generate select portions of MMM input data (ie campaign/channel spend)

Installation

Accessable via PyPI

pip install pysimmmulator

Usage

PySiMMMulator's simulator can either be run on a step-by-step basis, or can be run single-shot by passing a config file.

Run via config

Run using this method, you'll be returned both a dataframe of for MMM input as well as the "True ROI" values for each of your channels. These true values are critical to validating your MMM model.

cfg = load_config(config_path="./my_config.yaml")
sim = simmm()
mmm_input_df, channel_roi = sim.run_with_config(config=cfg)

Run via CLI

A configuration file is required as input for this and should be passed as seen below. An output path can also be passed via -o, however when not passed the current working directory will be used.

pysimmm -i example_config.yaml -o .

Run by stages

Alternatively you may run each of the stages independently, which allows for easier debugging and in-run adjustments based on the results of each stage. The order of the stages is reflected below (without their inputs). Once you've run through every stage, results are available by calling the sim.final_df object (channel ROI results are stored as sim.channel_roi).

sim = simmm()
sim.simulate_baseline()
sim.simulate_ad_spend()
sim.simulate_media()
sim.simulate_cvr()
sim.simulate_decay_returns()
sim.calculate_conversions()
sim.consolidate_dataframe()
sim.calculate_channel_roi()
sim.finalize_output()

Geographic distribution

Marketing Mix Models may use geographic grain data for the purposes of budget allocation or during the calibration phase. PySiMMMulator provies geos to facilitate the generation of rancomized geographies as well as a distribution funciton to allocated synthetic data across the geographies.

Study simulation

study and batch_study are also provided to simplify the simulated outcomes of marketing studies, which are an important component of MMM calibration.

Within this framework studies results are drawn from a normal distribution about the true value of a channels effectiveness (defaulted to ROI within this package). Both study and batch_study provide the ability to pass bias and standard deviation prameters for stationary and non-stationary distributions—allowing users to replicate a diverse set of real-world measurement difficulties.

Development

Setting up a dev environment

python3 -m venv venv
source venv/bin/activate
pip install -e '.[dev]'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysimmmulator-0.5.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysimmmulator-0.5.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file pysimmmulator-0.5.0.tar.gz.

File metadata

  • Download URL: pysimmmulator-0.5.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysimmmulator-0.5.0.tar.gz
Algorithm Hash digest
SHA256 5aeb3d1ee35d4e21e769b6cd84cade77c1a2b231b7f9c73955fcc05a1358ccb8
MD5 9ec2f4b8e45c6215de99c09a9581e6c2
BLAKE2b-256 28226cee37cadea113bca1190a9425d72dd2b7b04b21da0bd6ce6e32879f6338

See more details on using hashes here.

File details

Details for the file pysimmmulator-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pysimmmulator-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysimmmulator-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9d11953adeb0f7dd14f90da14ddb42792cc5bc78788ef68b78f558772cf71c5
MD5 b10b53bdd1395f6c136356a14b4d789e
BLAKE2b-256 349ae98e0f856c4d24e79150ad88753f5695707a234d2567e895348535ea0718

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page