An interactive, high-fidelity Marketing Mix Modeling (MMM) application designed for strategic budget optimization. This tool leverages Google Meridian for Bayesian inference and PySiMMMulator for high-fidelity marketing data simulation.
The application is structured into four progressive stages of marketing analysis:
- Detailed Global Setup: Configure years of data, seasonality variance, and growth trends.
- Advanced Channel Modeling: Define channel types (Impressions/Clicks), True CVR, and Cost (CPM/CPC).
- Native Modeling: Control Geometric Adstock (Lambda) and Hill Saturation (Alpha/Gamma) parameters with real-time preview charts.
- Bayesian Training: Execute actual Google Meridian MCMC sampling to learn parameters from historical data.
- "What-If" Analysis: Adjust total weekly investment and percentage-based channel allocations in real-time.
- ROI Alignment: Visualize where your current spend sits on the learned saturation curves.
- Channel Locking: Fix strategic budget mandates (e.g., "Brand must be 20%") and optimize the remainder.
- One-Click Optimization: Use the 🚀 Optimize Allocation button to find the mathematically ideal mix.
- Synthetic Data Audit: Fetch and visualize the underlying daily/weekly historical data.
- Dual-Axis Charting: Directly compare marketing activity (Spend/Impressions) against total bike purchases over time.
- Budget Sweep: Automatically simulate 100 discrete optimization points across a custom budget range.
- CPA Efficiency Curve: Identify the point of diminishing returns where acquisition costs begin to spike.
- Strategic Stacked Mix: Visualize how the optimal budget distribution shifts between channels as you scale your business.
The project follows a modular 3-tier architecture:
- Wrapper Layer (
wrapper/): Manages the integration with PySiMMMulator for data generation and Google Meridian for model training and analysis. - API Layer (
api/): A RESTful service built with Starlette that exposes the model's capabilities to the front-end. - UI Layer (
ui/): A professional, Google-branded dashboard built with Streamlit and Plotly.
Ensure you have the required virtual environment with meridian, pysimmmulator, streamlit, and starlette installed.
Use the unified startup script to launch both the backend and frontend simultaneously:
./run.sh [optional_path_to_venv]By default, the script looks for a virtual environment at ../bikevenv.
Once started, open your browser and navigate to:
http://localhost:8501
- Model: Google Meridian (Bayesian MMM)
- Simulation: PySiMMMulator
- API: Starlette / Uvicorn
- UI: Streamlit
- Visualizations: Plotly / Graph Objects
- Optimization: SciPy (SLSQP)
To stop both the API and UI processes, simply press Ctrl+C in the terminal running ./run.sh. The script includes a trap to ensure all background processes are terminated gracefully.