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 framework for simmulation of Marketing data for 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)

Originally predicated on adapting the R-package siMMMulator for python. PySiMMMulator has retained core function parallels to the functions of siMMMulator but has since expanded capabilities to support a far broader array of MMM inputs and utlities.

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")
simmm = Simulate()
mmm_input_df, channel_roi = simmm.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).

simmm = Simulate()
simmm.simulate_baseline()
simmm.simulate_ad_spend()
simmm.simulate_media()
simmm.simulate_cvr()
simmm.simulate_decay_returns()
simmm.calculate_conversions()
simmm.consolidate_dataframe()
simmm.calculate_channel_roi()
simmm.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 BatchStudy 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 BatchStudy 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.1.tar.gz (24.6 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.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysimmmulator-0.5.1.tar.gz
  • Upload date:
  • Size: 24.6 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.1.tar.gz
Algorithm Hash digest
SHA256 671117bd14fe7dcb8075e1a3ed8d3198dd556ae9998e466727a06aa9800c4699
MD5 6d57ae0dbed36bc8fde5bd530a6bc5e8
BLAKE2b-256 055b41b1dd9ad5c71904b135cacc321c951305b0b16a7b51286c2a995b4a3bc4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysimmmulator-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e024227c65e9a4364539449d7f01109550fef466943187c7436bcd5f62b18e9
MD5 03a766d9bb5b2664b3b6bc90f19611aa
BLAKE2b-256 67ed8d3ea94dc605204cde580267fd3176c435ef74200ed87a20b10c54deec56

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