Git Product home page Git Product logo

pymc-marketing's Introduction

PyMC-Marketing

Build codecov docs Code style: black PyPI Version License

Unlock the power of marketing analytics with PyMC-Marketing – the open source solution for smarter decision-making. Media mix modeling and customer lifetime value modules allow businesses to make data-driven decisions about their marketing campaigns. Optimize your marketing strategy and unlock the full potential of your customer data.


Installation

Install and activate an environment (e.g. marketing_env) with the pymc-marketing package from conda-forge. It may look something like the following:

mamba create -c conda-forge -n marketing_env pymc-marketing
mamba activate marketing_env

See the official PyMC installation guide if more detail is needed.

For testing purposes, if you wish to install the main branch directly from GitHub:

pip install git+https://github.com/pymc-labs/pymc-marketing.git

Bayesian Media Mix Models (MMMs) in PyMC

In this package we provide an API for a Bayesian media mix model (MMM) specification following Jin, Yuxue, et al. “Bayesian methods for media mix modeling with carryover and shape effects.” (2017). Concretely, given a time series target variable $y_{t}$ (e.g. sales on conversions), media variables $x_{m, t}$ (e.g. impressions, clicks or costs) and a set of control covariates $z_{c, t}$ (e.g. holidays, special events) we consider a linear model of the form

$$ y_{t} = \alpha + \sum_{m=1}^{M}\beta_{m}f(x_{m, t}) + \sum_{c=1}^{C}\gamma_{c}z_{c, t} + \varepsilon_{t}, $$

where $\alpha$ is the intercept, $f$ is a media transformation function and $\varepsilon_{t}$ is the error therm which we assume is normally distributed. The function $f$ encodes the contribution of media on the target variable. Typically we consider two types of transformation: adstock (carry-over) and saturation effects.

Here you can find a simulated example:

  1. First, we describe the data genaration process of a simulated dataset.
  2. Next, we describe how to specify and fit a media mix model (as described above) using the pymc-marketing MMM's API.
  3. Finally, we describe the model results: channel constribution and ROAS estimation. We also show how the model recovers the parameters from the data generation process step.

References:


Bayesian CLVs in PyMC

Customer Lifetime Value (CLV) models are another important class of models. There are many different types of CLV models and it can be helpful to conceptualise them as fitting in a 2-dimensional grid as below. An excellent set of introduction slides to CLV's is provided in Probability Models for Customer-Base Analysis by Fader & Hardie (2009).

Examples

Non-contractual Contractual
Continuous Buying groceries Audible
Discrete Cinema ticket Monthly or yearly subscriptions

To explain further:

  • Contractual: In contractual settings, a customer has a contract which continues to be active until it is explicitly cancelled. Therefore, customer churn events are observed.

  • Non-contractual: In non-contractual settings, there is no ongoing contract that a customer has with a company. Instead, purchases can be ad hoc and churn events are unobserved.

  • Discrete: Here, purchases are made at discrete points in time. This obviously depends upon the timescale that we are working on, but typically a relevant time period would be a month or year. However it could be more granualar than this - think of taking the 2nd of 4 inter-city train journeys offered per day.

  • Continuous: In the continuous-time domain, purchases can be made at any point within a firms opening hours. For online ordering, this could be any point within a 24 hour cycle, or purchases in physical stores could be made at any point during the trading day.

In the documentation, we provide some examples on how to use the CLV API. We use the data from the lifetimes package to illustrate the models.


📞 Schedule a Consultation

Unlock your potential with a free 30-minute strategy session with our PyMC experts. Discover how open source solutions and pymc-marketing can elevate your media-mix models and customer lifetime value analyses. Boost your career and organization by making smarter, data-driven decisions. Don't wait—claim your complimentary session today and lead the way in marketing and data science innovation.

Using PyMC-Marketing and how PyMC Labs can help you

PyMC-Marketing uses the Apache 2.0 licence which permits commercial use, amongst other things.

If you want to build upon the package, please feel free to fork the repo and submit a pull request. If in doubt, please open an issue.

For companies that want to use PyMC-Marketing in production, PyMC Labs is available for consulting and training. We can help you build and deploy your models in production. We have experience with cutting edge Bayesian modelling techniques in general, and in particular with MMMs and CLVs. For example, see our video on Bayesian Marketing Mix Models: State of the Art and their Future.

pymc-marketing's People

Contributors

juanitorduz avatar ricardov94 avatar lucianopaz avatar larryshamalama avatar drbenvincent avatar tomicapretto avatar maresb avatar coltallen avatar oriolabril avatar cluhmann avatar michaelraczycki avatar garve avatar twiecki avatar wd60622 avatar

Watchers

James Cloos avatar  avatar

Forkers

sahandsydney

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.