Skip to content

Commit b3865fa

Browse files
Add Fivetran data loaders (#1887)
* Add Fivetran data loaders Added example CSV schemas for ad reports and Shopify orders under data/fivetran_examples. Introduced pymc_marketing/data/fivetran.py for loading these datasets, and included initial tests in tests/data/test_fivetran.py. * Change in name (typo) * Adding notebook * Changes * new image! * Refactor Fivetran ad reporting data processing Refactored process_fivetran_ad_reporting into smaller helper functions for input validation, aggregation, and output formatting. Improved docstrings for clarity and maintainability. Updated the related notebook to clean up outputs, fix markdown headers, and move code cells for better readability. --------- Co-authored-by: Juan Orduz <[email protected]>
1 parent 539fc27 commit b3865fa

File tree

9 files changed

+2910
-0
lines changed

9 files changed

+2910
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
model:
2+
class: pymc_marketing.mmm.multidimensional.MMM
3+
kwargs:
4+
date_column: "date"
5+
channel_columns: # explicit for reproducibility
6+
- facebook_ads_impressions
7+
- google_ads_impressions
8+
- tiktok_ads_impressions
9+
#
10+
target_column: "orders"
11+
12+
# --- media transformations ---------------------------------------
13+
adstock:
14+
class: pymc_marketing.mmm.GeometricAdstock
15+
kwargs: {l_max: 12} # any other hyper-parameters here
16+
17+
saturation:
18+
class: pymc_marketing.mmm.MichaelisMentenSaturation
19+
kwargs: {} # default α, λ priors inside the class
20+
21+
# ----------------------------------------------------------------------
22+
# (optional) sampler options you plan to forward to pm.sample():
23+
sampler_config:
24+
tune: 900
25+
draws: 500
26+
chains: 4
27+
random_seed: 42
28+
target_accept: 0.90
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source_relation,date_day,platform,account_id,account_name,campaign_id,campaign_name,ad_group_id,ad_group_name,ad_id,ad_name,clicks,impressions,spend,conversions,conversions_value
2+
google_ads.daily,2025-07-10,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG201,Search - Brand,AD301,Brand Text Ad,140,5000,105.00,12,300.00
3+
google_ads.daily,2025-07-10,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG202,Search - Generic,AD302,Generic Text Ad,95,3800,80.75,6,150.00
4+
facebook_ads.daily,2025-07-10,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG203,Carousel Ads,AD303,Carousel Creative 1,320,16000,224.00,20,450.00
5+
facebook_ads.daily,2025-07-10,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG204,Video Ads,AD304,Video Creative 1,210,14000,157.50,14,315.00
6+
tiktok_ads.daily,2025-07-10,TikTok Ads,ACC003,Umbrella LLC,CAM201,Awareness Push,AG301,In-Feed,AD401,TopView 15s,180,12000,135.00,9,180.00
7+
tiktok_ads.daily,2025-07-10,TikTok Ads,ACC003,Umbrella LLC,CAM201,Awareness Push,AG301,In-Feed,AD402,Spark Post,135,9000,94.50,7,140.00
8+
google_ads.daily,2025-07-11,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG201,Search - Brand,AD301,Brand Text Ad,150,5200,112.50,13,325.00
9+
google_ads.daily,2025-07-11,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG202,Search - Generic,AD302,Generic Text Ad,100,4000,85.00,7,175.00
10+
facebook_ads.daily,2025-07-11,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG203,Carousel Ads,AD303,Carousel Creative 1,330,16500,231.00,21,472.50
11+
facebook_ads.daily,2025-07-11,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG204,Video Ads,AD304,Video Creative 1,220,14500,165.00,15,337.50
12+
tiktok_ads.daily,2025-07-11,TikTok Ads,ACC003,Umbrella LLC,CAM201,Awareness Push,AG301,In-Feed,AD401,TopView 15s,190,12500,142.50,10,200.00
13+
tiktok_ads.daily,2025-07-11,TikTok Ads,ACC003,Umbrella LLC,CAM201,Awareness Push,AG301,In-Feed,AD402,Spark Post,143,9500,100.10,8,160.00
14+
google_ads.daily,2025-07-12,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG201,Search - Brand,AD301,Brand Text Ad,155,5400,116.25,14,350.00
15+
google_ads.daily,2025-07-12,Google Ads,ACC001,Acme Corp,CAM101,Back to School,AG202,Search - Generic,AD302,Generic Text Ad,103,4100,87.55,7,175.00
16+
facebook_ads.daily,2025-07-12,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG203,Carousel Ads,AD303,Carousel Creative 1,340,17000,238.00,22,495.00
17+
facebook_ads.daily,2025-07-12,Facebook Ads,ACC002,Globex Inc,CAM102,Summer Sale,AG204,Video Ads,AD304,Video Creative 1,230,15000,172.50,16,360.00

data/fivetran_examples/shopify_orders_schema.csv

Lines changed: 25 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/gallery/gallery.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ Welcome to the PyMC-Marketing example gallery! This gallery provides visual navi
3737
:::
3838
::::
3939

40+
### Data Connectors
41+
42+
::::{grid} 1 2 3 3
43+
:gutter: 3
44+
45+
:::{grid-item-card} MMM Fivetran Connectors
46+
:img-top: ../gallery/images/mmm_fivetran_connectors.png
47+
:link: ../notebooks/mmm/mmm_fivetran_connectors.html
48+
:::
49+
::::
50+
4051
### Budget Allocation
4152

4253
::::{grid} 1 2 3 3
4.14 KB
Loading

0 commit comments

Comments
 (0)