How deejayrusso/marketing-mix-model works
Project type and purpose
• This is a data‐science/analytics pipeline—a marketing mix modeling project—rather than a multi‐tier web application.
• Purpose: generate simulated weekly media‐spend & sales data, engineer features, train multiple regression models (OLS, polynomial, Lasso, Ridge, Elastic Net, SGD) to predict sales from TV and paid‐search spend, and surface the best model.
File structure
• Top level:
– Data Generation – AMSS.R → R script invoking the AMSS package to simulate time‐series marketing & sales data
– ObservedData.csv → the resulting simulated data
– Marketing Mix Model – final.ipynb → Jupyter notebook containing data loading, EDA, feature engineering, model training, evaluation, and interpretation
– Marketing Mix Model Presentation.pdf → export of findings and visualizations
– README.md → project overview, methodology, and future directions
• No separate “src” or “lib” folders, so the notebook itself orchestrates data ingestion, transformation, modeling, and visualization.
README for additional insights
• External dependencies:
– R AMSS package for data simulation
– Python data stack (pandas, numpy, scikit-learn, matplotlib/seaborn) in the notebook
• Workflow steps are enumerated (1 through 10), outlining the pipeline from data generation through model comparison and interpretation.
Main components and interactions (to include
a. Data Generation Component
– “Data Generation – AMSS.R” calls AMSS, outputs ObservedData.csv
b. Raw Data Storage
– ObservedData.csv sits in a staging area
c. Data Ingestion & Exploration Module
– Notebook cell group “Generate data and load simulated data” and “Explore data”
d. Feature Engineering Module
– Notebook cells creating lag variables & rolling averages
e. Data Pipeline / Preprocessing
– Split into train/test, apply Yeo-Johnson transforms, label encoding if any
f. Model Training & Evaluation Module
– Six model blocks (OLS, polynomial, Lasso, Ridge, Elastic Net, SGD)
– Calculation of RMSE, MAPE for train/test
g. Model Selection & Interpretation
– Compare metrics, select Lasso, interpret coefficients
h. Output & Reporting
– Notebook visualizations, “Marketing Mix Model Presentation.pdf”
Relationships and data flow
1. R script → CSV
2. CSV → Notebook Ingestion
3. Ingestion → EDA → Feature Engineering → Preprocessing → Model Training → Evaluation → Selection
4. Final results → PDF report / visualizations
• Feedback loops if re-running the simulation or tuning hyperparameters
Architectural patterns and design principles
• Pipeline pattern: linear ETL (Extract → Transform → Load) feeding into model training
• Modularity: each notebook section acts as a module; maintain clear separation
• Reproducibility: record exact AMSS version, Python environment, random seeds
Key technologies, frameworks, and libraries
• R & AMSS package (data simulation)
• Python (Jupyter, pandas, numpy, scikit-learn, scipy, matplotlib/seaborn)
• GitHub for version control, README for documentation
Essential architectural elements in detail
• Call out the transformation stage (Yeo-Johnson) as it materially affects interpretability.