Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing Robynpy - Robyn powered by Python. #1183

Merged
merged 331 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
331 commits
Select commit Hold shift + click to select a range
67dc71f
add unit tests
alxlyj Sep 30, 2024
246e86b
update modeling code
alxlyj Oct 1, 2024
b350f09
remove unit test
alxlyj Oct 1, 2024
b872457
update modeling code and scripts
alxlyj Oct 1, 2024
8b7cbe1
update ridge model builder
alxlyj Oct 1, 2024
bd29e66
update tutorial notebook
alxlyj Oct 1, 2024
7e8d67e
add placeholders for feature_engineering unit test
alxlyj Oct 1, 2024
abaa3f9
Merge pull request #1065 from facebookexperimental/review_ready_imple…
alxlyj Oct 1, 2024
66fb315
add data mapper
alxlyj Oct 1, 2024
15db1cb
update modeling code
alxlyj Oct 1, 2024
90c1874
update data classes and modeling code
alxlyj Oct 1, 2024
024e0c9
add placeholder unit tests
alxlyj Oct 2, 2024
d5a7411
remove plotter functions from ridge_model_builder
alxlyj Oct 2, 2024
a7e3709
add convergence implementation
alxlyj Oct 2, 2024
42a2c96
remove old code from model_builder
alxlyj Oct 2, 2024
f1046b9
add new convergence code
alxlyj Oct 2, 2024
5062f62
update convergence code
alxlyj Oct 2, 2024
39619b7
remove data mapper from modeling
alxlyj Oct 2, 2024
a449677
rename files
alxlyj Oct 2, 2024
db95d56
Merge branch 'robynpy_release' into review_ready_impl_modeling_new
alxlyj Oct 2, 2024
9352511
update feature eng notebook
alxlyj Oct 2, 2024
a09e63e
update feature eng notebook
alxlyj Oct 2, 2024
22a6017
update modeling notebook
alxlyj Oct 2, 2024
e0458e7
Merge pull request #1067 from facebookexperimental/review_ready_impl_…
alxlyj Oct 2, 2024
afa48d7
add data mapper code
alxlyj Oct 1, 2024
0008b51
add data mapper src code
alxlyj Oct 1, 2024
f6ae085
update data mapper notebook
alxlyj Oct 1, 2024
440c667
update data mapper code
alxlyj Oct 4, 2024
1e845ae
update data mapper code
alxlyj Oct 4, 2024
9bf2304
update data mapper code initializations
alxlyj Oct 4, 2024
0f2e590
add calibration input validation implementation
shivkanthb Oct 4, 2024
b3baeab
visualizer classes
shivkanthb Oct 4, 2024
582b957
Delete visualizer.py
shivkanthb Oct 4, 2024
3f2392e
update data_mapper
alxlyj Oct 6, 2024
f3b8ad8
Update robyn_visualizer.py
shivkanthb Oct 7, 2024
2deb356
Update input_visualizer.py
shivkanthb Oct 7, 2024
70f4560
Merge pull request #1062 from facebookexperimental/feature/visualizat…
shivkanthb Oct 8, 2024
4f62566
Merge branch 'robynpy_release' of https://github.com/facebookexperime…
shivkanthb Oct 9, 2024
e4a2518
calibration_input_validation
shivkanthb Oct 9, 2024
9ae5df0
update code
alxlyj Oct 9, 2024
640812c
fix import
alxlyj Oct 9, 2024
f1a4aac
Merge pull request #1066 from facebookexperimental/feature/new_data_m…
alxlyj Oct 9, 2024
1395ac1
Merge pull request #1070 from facebookexperimental/feature/calibratio…
shivkanthb Oct 9, 2024
e5809b1
fix code and indents
alxlyj Oct 10, 2024
a76b970
remove print logs
alxlyj Oct 10, 2024
163a366
Merge pull request #1072 from facebookexperimental/feature/fix_data_m…
alxlyj Oct 10, 2024
c4a37d2
Updating pareto-optimizer until it generates plot data (#1075)
dhavalpatel624624 Oct 14, 2024
8ae158b
Added tranformations.py and moved logic from response_curve to transf…
Oct 16, 2024
394f869
first commit
alxlyj Oct 17, 2024
e9ce377
push fix to modeling code
alxlyj Oct 17, 2024
ab70674
update notebook code
alxlyj Oct 17, 2024
ecec62d
update notebook code
alxlyj Oct 17, 2024
a8d5f72
remove .env.sample
alxlyj Oct 17, 2024
fefd8e2
tidy up feature eng
alxlyj Oct 17, 2024
a22c8d1
tidy up feature eng
alxlyj Oct 17, 2024
636a238
update notebook
alxlyj Oct 17, 2024
5fd9b2d
Merge pull request #1077 from facebookexperimental/feature/fix_modeli…
alxlyj Oct 17, 2024
0116cf3
first commit
alxlyj Oct 21, 2024
f5943c8
update model_run calls for using Hyperparameters data class
alxlyj Oct 21, 2024
c7b1d59
update print to loggers
alxlyj Oct 21, 2024
bbde3e4
update prints to loggers for modelling
alxlyj Oct 21, 2024
6d08ba5
address slicing warning
alxlyj Oct 21, 2024
940970a
update notebooks, update train_size dtype
alxlyj Oct 21, 2024
afb6d96
Merge pull request #1079 from facebookexperimental/feaeture/fix_hyper…
sumane81 Oct 22, 2024
6e3bad4
Finalized transformations log and more of _generate_plot_data
Oct 22, 2024
0652241
first commit
alxlyj Oct 17, 2024
7441204
push fix to modeling code
alxlyj Oct 17, 2024
5f66aa8
update notebook code
alxlyj Oct 17, 2024
4ccbd4e
update notebook code
alxlyj Oct 17, 2024
04e52d1
remove .env.sample
alxlyj Oct 17, 2024
0d8730f
tidy up feature eng
alxlyj Oct 17, 2024
0b11141
tidy up feature eng
alxlyj Oct 17, 2024
6d749e5
update notebook
alxlyj Oct 17, 2024
91c4eab
first commit
alxlyj Oct 21, 2024
49812ce
update model_run calls for using Hyperparameters data class
alxlyj Oct 21, 2024
a8de04a
update print to loggers
alxlyj Oct 21, 2024
f9c2c3a
update prints to loggers for modelling
alxlyj Oct 21, 2024
9a23f81
address slicing warning
alxlyj Oct 21, 2024
ee3008b
update notebooks, update train_size dtype
alxlyj Oct 21, 2024
d2370bf
minor renaming
Oct 22, 2024
686a478
Adding model_run to robyn.py and updating tutorial1
sumane81 Oct 22, 2024
0dd1149
Merge pull request #1081 from facebookexperimental/feature/robyn_abst…
sumane81 Oct 22, 2024
b287729
fixed transformer and pareto_optimizer
Oct 22, 2024
3558719
updated notebook
Oct 22, 2024
4b9b5ce
Merge remote-tracking branch 'origin/robynpy_release' into robynpy_pa…
Oct 22, 2024
b1a6ef3
Adding feature engineering unit test cases and Bumping up robynpy pac…
sumane81 Oct 22, 2024
5b8c337
fixing simulated data file path
sumane81 Oct 22, 2024
1470bb4
Adding upload artifacts
sumane81 Oct 22, 2024
7315f29
Fixing typo
sumane81 Oct 22, 2024
e5daf03
Upload artifact fix
sumane81 Oct 22, 2024
1b55928
Output artifact action fixture
sumane81 Oct 22, 2024
46a5906
testing upload artifact
sumane81 Oct 22, 2024
eeb20cb
Uploading coverage artifact
sumane81 Oct 22, 2024
5250916
Generating html coverage
sumane81 Oct 22, 2024
893426c
Fixed html coverage artifact
sumane81 Oct 22, 2024
8f66a7a
Removing support for 3.9
sumane81 Oct 22, 2024
9741c53
Changes that provide 99% accuracy with pareto_optimizer
Oct 23, 2024
5287d4e
fixed lint errors and cleaned up notebook
Oct 23, 2024
589ec66
build failure fixes
Oct 23, 2024
2070461
Merge pull request #1083 from facebookexperimental/feature/calibration
sumane81 Oct 23, 2024
ef23f18
Merge pull request #1080 from facebookexperimental/robynpy_pareto_plo…
sumane81 Oct 24, 2024
f280456
feature: add code for calibration (#1084)
alxlyj Oct 25, 2024
a1a5679
cluster builder interface and updated output (#1089)
dhavalpatel624624 Oct 25, 2024
9328e5d
Add hillcalculator test
Oct 29, 2024
df0c07b
Updating module init file with logging config
sumane81 Oct 29, 2024
6941c06
Update __init__.py
sumane81 Oct 29, 2024
5158359
Merge pull request #1097 from facebookexperimental/loggingconfigupdate
sumane81 Oct 30, 2024
6f0df72
Add tests for response_curve
Oct 30, 2024
56325ea
Fix code as slice (a,b) a is inclusive, b is exclusive
Oct 30, 2024
953e07b
Updating logging config
sumane81 Oct 30, 2024
3811ef5
[feature/experimental] add outputcollect to data mapper script util (…
alxlyj Oct 30, 2024
dc9d61d
[feature] add allocator (#1088)
alxlyj Oct 31, 2024
cb08ab3
Moving tutorials inside robyn so it gets included in PyPi package
sumane81 Oct 31, 2024
3fe97cc
One pager interface
sumalreddy17 Oct 29, 2024
59f955d
One page visualizer
sumalreddy17 Oct 31, 2024
8829428
fix One page visualizer
sumalreddy17 Oct 31, 2024
28fa788
Removed unused imports and move one pager under reporting.
sumalreddy17 Oct 31, 2024
7999f7f
Removed additional empty line and added a todo
sumalreddy17 Oct 31, 2024
6304508
Minor formatting changes
sumalreddy17 Oct 31, 2024
bf2b2e2
Resolve merge conflicts and addressed fiel name change
sumalreddy17 Oct 31, 2024
78d19b4
Merge branch 'loggingconfigupdate' of https://github.com/facebookexpe…
sumane81 Oct 31, 2024
83baa42
Merge pull request #1096 from facebookexperimental/feature_export_one…
sumalreddy17 Oct 31, 2024
d40ac70
Putting back tutorial6
sumane81 Oct 31, 2024
0241756
Fixing resource path in unit test case
sumane81 Nov 1, 2024
2eaf970
Merge pull request #1103 from facebookexperimental/loggingconfigupdate
sumane81 Nov 1, 2024
c17ded5
[fix] plot_data_collect on paretoresults (#1105)
alxlyj Nov 4, 2024
dd6ddb6
Fix bug that thrown an error if data_range was a list.
Nov 4, 2024
0986bb6
Commit for running test workflow
Nov 4, 2024
cee1740
Merge pull request #1101 from facebookexperimental/test/unit_tests_fo…
Marco-Premier Nov 4, 2024
ddd271a
added clustering tutorial and changed model entities (#1106)
dhavalpatel624624 Nov 5, 2024
2cc846e
Robynpy pareto cleanup with 100% accuracy now
dhavalpatel624624 Nov 5, 2024
f2753d8
waterfall plot implementation
sumalreddy17 Nov 5, 2024
cca117f
Add minor fix
sumalreddy17 Nov 5, 2024
da88895
Robyn one pager: fitted_vs_actual plot implementation
sumalreddy17 Nov 6, 2024
b881040
[test] add feature eng unit test and refactor unit test dir. (#1110)
alxlyj Nov 6, 2024
f08cbb8
Robyn one pager: generate_diagnostic_plot plot implementation
sumalreddy17 Nov 6, 2024
e3bd5e2
Merge pull request #1095 from facebookexperimental/test/add_unit_test…
Marco-Premier Nov 6, 2024
06f3ed8
Cluster_builder implementation (#1108)
dhavalpatel624624 Nov 6, 2024
e6c6a5a
Update convergence.py
sumane81 Nov 6, 2024
c43727b
Robyn one pager: Ad stock and immediate_vs_carryover implementation
sumalreddy17 Nov 6, 2024
182b989
Merge pull request #1116 from facebookexperimental/logging_1
sumane81 Nov 6, 2024
20ef796
[refactor] refactor modeling code (#1115)
alxlyj Nov 7, 2024
a80dfe6
generated base_visualizer and allocator_plotter using ai-codegen (#1114)
Marco-Premier Nov 7, 2024
bb39e92
Merge pull request #1113 from facebookexperimental/generate_diagnosti…
sumalreddy17 Nov 7, 2024
ca1b8ce
Merge branch 'robynpy_release' into waterfall_plot
sumalreddy17 Nov 7, 2024
a3dc442
fix lint error
sumalreddy17 Nov 7, 2024
e25e758
Merge pull request #1111 from facebookexperimental/waterfall_plot
sumalreddy17 Nov 7, 2024
023f346
Merge branch 'robynpy_release' into generate_fitted_vs_actual
sumalreddy17 Nov 7, 2024
67a2ed7
Merge pull request #1112 from facebookexperimental/generate_fitted_vs…
sumalreddy17 Nov 7, 2024
b927653
Merge branch 'robynpy_release' into ad_stock
sumalreddy17 Nov 7, 2024
613cbe5
Address review comments
sumalreddy17 Nov 7, 2024
6cb6556
Merge pull request #1117 from facebookexperimental/ad_stock
sumalreddy17 Nov 7, 2024
8e79c92
Robyn one pager: generate_spend_effect_comparison plot implementation
sumalreddy17 Nov 7, 2024
a007162
Remove debug logs
sumalreddy17 Nov 7, 2024
9954858
Merge pull request #1122 from facebookexperimental/spend_effect
sumalreddy17 Nov 8, 2024
32b938f
new integration fixes (#1119)
alxlyj Nov 8, 2024
bdfb1e1
Robyn one pager: Response curve plot implementation
sumalreddy17 Nov 8, 2024
b48df22
Robynpy clustering plots implementation (#1120)
dhavalpatel624624 Nov 8, 2024
1f3ddcf
Merge pull request #1123 from facebookexperimental/response_curve
sumalreddy17 Nov 8, 2024
b0aa552
[feature] update robyn apis (#1125)
alxlyj Nov 8, 2024
6a70206
Removed default value of cores
sumane81 Nov 8, 2024
98af284
Added Common Utils
sumane81 Nov 8, 2024
2ee0d57
Updated cores
sumane81 Nov 8, 2024
0305036
Merge pull request #1126 from facebookexperimental/cores_update
sumane81 Nov 8, 2024
6bc54e9
Added logging
sumane81 Nov 8, 2024
f3eff94
Added AI generated logging to most classes
sumane81 Nov 9, 2024
ad2dc98
Fixed errors related to auto generated logging
sumane81 Nov 10, 2024
757c124
Adding back _hill_function due to unit test failure
sumane81 Nov 10, 2024
7b66d09
Added logging to budget_allocator
sumane81 Nov 10, 2024
71c643d
Added logging to cluster_builder
sumane81 Nov 11, 2024
acb3308
Merge pull request #1127 from facebookexperimental/logging_1
sumane81 Nov 11, 2024
954ae43
Robyn one pager: bootstrap plot implementation (#1118)
sumalreddy17 Nov 11, 2024
5dd6080
One pager reporter initializing viz and calling plot functions. (#1124)
sumalreddy17 Nov 11, 2024
82b5137
Added logging to visualizer components
sumane81 Nov 12, 2024
ec87b24
fixed bug
sumane81 Nov 12, 2024
171e05d
Robynpy pareto bugfix (#1128)
dhavalpatel624624 Nov 12, 2024
4910467
Delete allocator_visualizer_original.py
sumane81 Nov 12, 2024
2e42934
Delete robyn_visualizer.py
sumane81 Nov 12, 2024
cbfc283
Merge pull request #1131 from facebookexperimental/viz_logging
sumane81 Nov 12, 2024
943af54
changed solID column names to sol_id (#1129)
dhavalpatel624624 Nov 12, 2024
00400af
one pager end to end integration.
sumalreddy17 Nov 13, 2024
bf67b16
Minor fixes
sumalreddy17 Nov 13, 2024
5177336
[integration] re-run e2e integration through modeling (#1134)
alxlyj Nov 13, 2024
0f0f78a
clustering Plot fixes with better accuracy and Pareto minor change (#…
dhavalpatel624624 Nov 13, 2024
ca170bc
fixed logging level inside exception
sumalreddy17 Nov 13, 2024
b657644
Merge pull request #1133 from facebookexperimental/one_pager_final
sumalreddy17 Nov 13, 2024
ede2aa8
enhance OnePagerReporter with PlotType enum and validation
sumalreddy17 Nov 13, 2024
e57eb97
Addressing comments
sumalreddy17 Nov 14, 2024
c839103
dynamic placing of plots.
sumalreddy17 Nov 14, 2024
3902c54
Adding ToDo
sumalreddy17 Nov 14, 2024
cb6a4a7
Merge pull request #1137 from facebookexperimental/error_handling
sumalreddy17 Nov 14, 2024
5f963b7
Integrated pareto clustering and visualizers (#1139)
dhavalpatel624624 Nov 14, 2024
d2452e8
[integration] Integration/e2e robyn all (#1138)
alxlyj Nov 15, 2024
09e0b7f
Update base_visualizer.py
sumane81 Nov 16, 2024
997c7cd
Pareto e2e allocator (#1142)
dhavalpatel624624 Nov 16, 2024
0178c0b
Merge pull request #1143 from facebookexperimental/feature/base_visua…
sumane81 Nov 16, 2024
5eab567
Refactored robyn.py with visualizer call
sumane81 Nov 16, 2024
bc47db6
Merge pull request #1145 from facebookexperimental/refactor/robyn_api
sumane81 Nov 16, 2024
4257b04
added plot_all in all visualizers and common display functionality to…
sumane81 Nov 18, 2024
648d48d
Merge pull request #1146 from facebookexperimental/refactor/plot_all
sumane81 Nov 18, 2024
86d1c98
Pass featurized mmm data to FeaturePlotter instance creation.
sumalreddy17 Nov 18, 2024
96c0358
Merge pull request #1149 from facebookexperimental/viz_accuracy
sumalreddy17 Nov 18, 2024
8c46a29
Robynpy bugfix graphs (#1150)
dhavalpatel624624 Nov 18, 2024
6ef7fdf
[accuracy] fix accuracies on input and modeling. (#1151)
alxlyj Nov 19, 2024
f8e7a8c
added formatting with black-formatter (#1153)
dhavalpatel624624 Nov 20, 2024
3b048d7
test allocator changes
alxlyj Nov 20, 2024
c50c5cb
Fix spend effect graph
sumalreddy17 Nov 20, 2024
1611ad8
Added offset to move labels right of dots
sumalreddy17 Nov 20, 2024
a0bbbc2
More fixes for one pager
sumalreddy17 Nov 20, 2024
924a3d3
Further fixes to match accuracy
sumalreddy17 Nov 20, 2024
40d6122
update allocator notebooks
alxlyj Nov 20, 2024
fc1f136
allocator accuract fixes
alxlyj Nov 20, 2024
5bdbd6a
working code for allocator
alxlyj Nov 20, 2024
98cb63e
fix vertical lines in fitted vs actual
sumalreddy17 Nov 21, 2024
cb60234
improved allocator algorithms
alxlyj Nov 21, 2024
fa44120
improve allocator accuracy
alxlyj Nov 21, 2024
435242a
allocator accuracy fixes
alxlyj Nov 21, 2024
b35dc07
update plots
alxlyj Nov 21, 2024
bb61a67
update robynpy calls
alxlyj Nov 21, 2024
6b0cff9
cleanup deprecated files
alxlyj Nov 21, 2024
e644ce4
Merge pull request #1155 from facebookexperimental/accuracy/allocator…
sumane81 Nov 21, 2024
44ddabc
fix the accuracy for alll 8 plots in one pager
sumalreddy17 Nov 21, 2024
c6f879b
[fixes] update e2e notebooks, improve accuracy for allocator scenario…
alxlyj Nov 21, 2024
158668f
Merge branch 'robynpy_release' into sort_one_pager_graph_labelling
sumalreddy17 Nov 21, 2024
6c36bf3
Verify formatting.
sumalreddy17 Nov 21, 2024
b295b14
Clean up and reformat
sumalreddy17 Nov 21, 2024
0e601a0
Merge pull request #1154 from facebookexperimental/sort_one_pager_gra…
sumalreddy17 Nov 22, 2024
5e15e95
extract model metrics and optimize the one pager code (#1158)
sumalreddy17 Nov 22, 2024
9b75fc2
Robyn one pager end to end flow for tutorial 1
sumalreddy17 Nov 22, 2024
d832ea8
Format files
sumalreddy17 Nov 22, 2024
b9c7497
Allow user to pass in a single solution id from client interface layer
sumalreddy17 Nov 22, 2024
c19636e
Address comments
sumalreddy17 Nov 22, 2024
f0e6322
Merge pull request #1160 from facebookexperimental/onepager_e2e
sumalreddy17 Nov 22, 2024
209513b
Added 4 new graphs to Pareto Optimizer + bug fixes (#1159)
dhavalpatel624624 Nov 22, 2024
9332be4
close the pyplot before return
sumalreddy17 Nov 22, 2024
ad0af90
Merge pull request #1163 from facebookexperimental/fix_spend_exposure…
sumalreddy17 Nov 22, 2024
24665fd
Update/requirements.txt (#1162)
alxlyj Nov 22, 2024
78423ff
[fix] accuracy e2e (#1168)
alxlyj Dec 2, 2024
dc8e309
refactored pareto_optimizer code (#1171)
dhavalpatel624624 Dec 4, 2024
72c9f38
change the order of one pager plots (#1172)
sumalreddy17 Dec 4, 2024
634980b
[switch] ridge modeling version to better match convergence for initi…
alxlyj Dec 5, 2024
0b98a2f
Code cleanup and proper logging for pareto and clustering (#1180)
dhavalpatel624624 Dec 6, 2024
7c020a1
[accuracy] modeling changes for calculate_decomp_spend_dist (#1175)
alxlyj Dec 6, 2024
f8a0c90
Robynpy readme updates (#1169)
dhavalpatel624624 Dec 6, 2024
b6c4d63
Moving tutorials into tests and organizing tests
sumane81 Dec 6, 2024
64a1f25
Merge pull request #1178 from facebookexperimental/tutorials_cleanup
sumane81 Dec 6, 2024
14e6713
[cleanup] cleanup loggers for console/notebook (#1181)
alxlyj Dec 6, 2024
7ff5ccc
update colab notebooks (#1182)
alxlyj Dec 7, 2024
1cbe9e8
Bumping up python release to 0.1.1
sumane81 Dec 9, 2024
988913d
Merge pull request #1185 from facebookexperimental/realease_0.1.1
sumane81 Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# A continuous integration (CI) workflow to build and test Robyn Python project

name: Robyn Python application

on:
push:
branches: ['robynpy_release']
pull_request:
branches: ['robynpy_release']

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: updating PATH to enable importing robyn modules
run: |
echo "PYTHONPATH=$PYTHONPATH:$(pwd)/python/src" >> $GITHUB_ENV

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [ -f python/requirements.txt ]; then pip install -r python/requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=./robyn_api/*.py
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=./robyn_api/*.py
- name: Test with pytest. Enable this once first set of tests are written
run: |
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=robyn --cov-report=html
- name: 'Upload Unit Test Results'
uses: actions/upload-artifact@v4
with:
name: robynpy-output-artifact
path: junit/test-results.xml
retention-days: 30
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov
retention-days: 30
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DS_Store
.Rproj.user
.Rhistory
.venv/
robynpy.egg-info/
node_modules/
RobynApp.Rcheck/00_pkg_src/RobynApp/R/ui.R
RobynApp.Rcheck/00_pkg_src/RobynApp/README.md
Expand Down Expand Up @@ -31,3 +33,22 @@ RobynApp.Rcheck/RobynApp/R/RobynApp.rdb
RobynApp.Rcheck/RobynApp/R/RobynApp.rdx
RobynApp_1.0.0.tar.gz
Robyn_Fork.Rproj
python/src/tutorials/demo.py
python/.venv
python/**/.venv
python/dist
python/**/__pycache__
python/.vscode
python/src/robynpy.egg-info*
python/oldportedcode
python/src/tutorials/mytestenv
*.log
python/src/tutorials/test_modeling.py
python/src/tutorials/data/*
python/src/tutorials/test_modeling.py
python/src/tutorials/data/R/*
python/src/tutorials/data/*
*.pkl
python/src/robyn/_deprecate/*
python/src/robyn/tutorials/output/*
python/src/robyn/debug/*
21 changes: 21 additions & 0 deletions python/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Meta Platforms, Inc. and its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Robyn: Continuous & Semi-Automated MMM <img src='R/man/figures/logo.png' align="right" height="139px" />
### The Open Source Marketing Mix Model Package from Meta Marketing Science

<!-- [![Pypi\_Status\_Badge](https://www.r-pkg.org/badges/version/Robyn)](https://cran.r-project.org/package=Robyn) [![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/Robyn?color=green)](https://cranlogs.r-pkg.org/badges/grand-total/Robyn?color=green) [![Site](https://img.shields.io/badge/site-Robyn-blue.svg)](https://facebookexperimental.github.io/Robyn/) [![Facebook](https://img.shields.io/badge/group-Facebook-blue.svg)](https://www.facebook.com/groups/robynmmm/) [![CodeFactor](https://www.codefactor.io/repository/github/facebookexperimental/robyn/badge)](https://www.codefactor.io/repository/github/facebookexperimental/robyn) -->
---

## Introduction

* **What is Robyn?**: Robyn is an experimental, semi-automated and open-sourced Marketing Mix Modeling (MMM) package from Meta Marketing Science. It uses various machine learning techniques (Ridge regression, multi-objective evolutionary algorithm for hyperparameter optimization, time-series decomposition for trend & season, gradient-based optimization for budget allocation, clustering, etc.) to define media channel efficiency and effectivity, explore adstock rates and saturation curves. It's built for granular datasets with many independent variables and therefore especially suitable for digital and direct response advertisers with rich data sources.

* **Why are we doing this?**: MMM used to be a resource-intensive technique that was only affordable for "big players". As the privacy needs of the measurement landscape evolve, there's a clear trend of increasing demand for modern MMM as a privacy-safe solution. At Meta Marketing Science, our mission is to help all businesses grow by transforming marketing practices grounded in data and science. It's highly aligned with our mission to democratizing MMM and making it accessible for advertisers of all sizes. With Project Robyn, we want to contribute to the measurement landscape, inspire the industry and build a community for exchange and innovation around the future of MMM and Marketing Science in general.

## Quick start for Python (Beta)

The Python version of Robyn is rewritten from Robyn's R package version `3.11.1` to Python using object oriented programming principles and modular architecture for a robust solution. It was developed by utilizing various LLMs and AI workflows. As is common with any AI-based solutions, there may be potential challenges in translating code from one language to another.
In this case, we anticipate that there could be some issues in the translation from R to Python. However, we believe in the power of community collaboration and open-source contribution. Therefore, we are opening this project to the community to participate and contribute.
Together, we can address and resolve any issues that may arise, enhancing the functionality and efficiency of the Python version of Robyn. We look forward to your contributions and to the continuous improvement of this project.

**1. Installing the package**

* Install Robyn latest package version:
```{r}
## Pypi
pip3 install robynpy

## DEV VERSION
# if you are pulling source from github, install dependencies using requirements.txt
pip3 install -r requirements.txt
```

**2. Getting started**

* python/src/robyn/tutorials contains tutorials for most common scenarios. Tutorials use simulated dataset provided in the package.

* There are two ways of running Python Robyn; one is `tutorial1.ipynb` and second is `tutorial1_src.ipynb`.

**3. Running end-to-end**

Option 1:
* `tutorial1.ipynb` is the main notebook that runs the end-to-end flow. It is designed for majority of the users who would prefer a one click solution that runs the robyn flow end-to-end with minimal knowledge of the underlying logic. It should run without any changes required if you wish to use the simulated dataset for testing purposes.

* This notebook uses APIs available in `python/src/robyn/robyn.py` to set the configs, run feature engineering, run model training, evaluate models with clustering, generate one pagers and perform budget allocation.

* Change any of the configs directly in the notebook and avoid changes to robyn.py for what can be configurable.

Option 2:
* `tutorial1_src.ipynb` runs the end-to-end flow of robyn python but with a lot more flexibility. It is designed for users who would like to have more control over which modules are and aren't run (ie. skipping clustering/one pager plots/budget allocation etc.). It should run without any changes required if you wish to use the simulated dataset for testing purposes.

* This notebook doesn't use APIs available in `python/src/robyn/robyn.py` but instead, calls the modules directly with the appropriate parameters. In this way, it is more flexible but still expects the users to understand the underlying logic that may change when using various parameter values.

## Helpful Links

* Visit our [website](https://facebookexperimental.github.io/Robyn/) to explore more details about Project Robyn.

* Join our [public group](https://www.facebook.com/groups/robyn/) to exchange with other users and interact with team Robyn.

* Take Meta's [official Robyn blueprint course](https://www.facebookblueprint.com/student/path/253121-marketing-mix-models?utm_source=readme) online

## License

Meta's Robyn is MIT licensed, as found in the LICENSE file.

- Terms of Use - https://opensource.facebook.com/legal/terms
- Privacy Policy - https://opensource.facebook.com/legal/privacy
- Defensive Publication - https://www.tdcommons.org/dpubs_series/4627/

## Contact

* [email protected], Gufeng Zhou, Marketing Science, Robyn creator
* [email protected], Igor Skokan, Marketing Science Director, open source
181 changes: 181 additions & 0 deletions python/docs/robyn/modeling/feature_engineering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# CLASS
## FeaturizedMMMData
* This class is a data container specifically used to store the results of feature engineering for Marketing Mix Modeling (MMM) data.
* It holds the modulated data, rolling window modulated data, and the results from non-linear models.
* This class is located in the main file for feature engineering.

# CONSTRUCTORS
## FeaturizedMMMData `(dt_mod: pd.DataFrame, dt_modRollWind: pd.DataFrame, modNLS: Dict[str, Any])`
* **dt_mod**: A pandas DataFrame that contains the modulated data after feature engineering.
* **dt_modRollWind**: A pandas DataFrame representing the rolling window modulated data.
* **modNLS**: A dictionary that holds the results of non-linear model fitting, with keys as model names and values as model outcomes.

### USAGE
* The constructor is used to instantiate a `FeaturizedMMMData` object, encapsulating the results of feature engineering for further analysis or modeling.

### IMPL
* The `@dataclass` decorator is employed, which automatically provides an `__init__` method that initializes class attributes based on the provided parameters.

# CLASS
## FeatureEngineering
* This class is designed to carry out feature engineering specifically for Marketing Mix Modeling (MMM) data.
* It incorporates external data such as holidays and utilizes statistical models to transform and prepare data for analysis.
* The class is located in the main file dedicated to feature engineering tasks.

# CONSTRUCTORS
## FeatureEngineering `(mmm_data: MMMData, hyperparameters: Hyperparameters, holidays_data: Optional[HolidaysData] = None)`
* **mmm_data**: An instance of `MMMData` that includes the dataset and specifications required for MMM.
* **hyperparameters**: An instance of `Hyperparameters` that configures the feature engineering process.
* **holidays_data**: An optional instance of `HolidaysData`, used to include holiday effects via Prophet decomposition.

### USAGE
* Instantiate this class when there is a need to perform feature engineering on MMM data using specific hyperparameters, with the option to factor in holidays data.

### IMPL
* The constructor initializes class variables such as `mmm_data`, `hyperparameters`, `holidays_data`, and a logger instance.
* The logger is set up using Python's `logging` library to log information and warnings throughout the feature engineering process.

# METHODS
## `perform_feature_engineering(quiet: bool = False) -> FeaturizedMMMData`
### USAGE
* **quiet**: A boolean flag to indicate whether logging output should be suppressed. Defaults to `False`.
* This method orchestrates the entire feature engineering process and returns a `FeaturizedMMMData` object containing the results.

### IMPL
* The method begins by preparing the initial dataset through `_prepare_data()`.
* It checks for the presence of Prophet variables and performs decomposition if required, logging the process unless `quiet` is set to `True`.
* Collects all relevant independent variables and transforms the dataset.
* Generates rolling window data and computes the media cost factor.
* Runs models using `_run_models()`.
* Filters columns to retain necessary data in the resulting DataFrames and addresses any missing values.
* Logs the completion of feature engineering if `quiet` is `False`.
* Finally, returns an instance of `FeaturizedMMMData` containing the processed data and model results.

## `_prepare_data() -> pd.DataFrame`
### USAGE
* Prepares the dataset by transforming the date and dependent variable columns for further processing.

### IMPL
* Copies the original data to avoid modifying the input directly.
* Converts the date column to a standardized `YYYY-MM-DD` format.
* Sets the dependent variable column for easier access and transformations.
* Ensures specific variable types, such as converting `competitor_sales_B` to `int64`.

## `_create_rolling_window_data(dt_transform: pd.DataFrame) -> pd.DataFrame`
### USAGE
* **dt_transform**: A pandas DataFrame representing the transformed dataset.
* Creates a rolling window dataset based on specified start and end dates for analysis.

### IMPL
* Filters the dataset according to the window start and end specifications provided in `mmm_data`.
* Raises a `ValueError` if the window specifications are inconsistent with the dataset, ensuring logical integrity.

## `_calculate_media_cost_factor(dt_input_roll_wind: pd.DataFrame) -> pd.Series`
### USAGE
* **dt_input_roll_wind**: A pandas DataFrame of the rolling window input data.
* Calculates the media cost factor for the given rolling window dataset.

### IMPL
* Computes the total spend from the specified paid media spends.
* Returns the media cost factor as a pandas Series, representing the proportion of spend for each media type.

## `_run_models(dt_modRollWind: pd.DataFrame, media_cost_factor: float) -> Dict[str, Dict[str, Any]]`
### USAGE
* **dt_modRollWind**: A pandas DataFrame containing rolling window modulated data.
* **media_cost_factor**: A float representing the media cost factor.
* Runs statistical models for each paid media variable and returns the results.

### IMPL
* Initializes a dictionary `modNLS` to store model results, yhat predictions, and plots.
* Iterates over each paid media variable, calling `_fit_spend_exposure()` to fit models.
* Aggregates model results into `modNLS` and returns it.

## `_fit_spend_exposure(dt_modRollWind: pd.DataFrame, paid_media_var: str, media_cost_factor: float) -> Dict[str, Any]`
### USAGE
* **dt_modRollWind**: A pandas DataFrame of rolling window modulated data.
* **paid_media_var**: A string representing the paid media variable.
* **media_cost_factor**: A float representing the media cost factor.
* Fits spend-exposure models for a given paid media variable and returns the results.

### IMPL
* Logs the processing of the paid media variable.
* Attempts to fit data using the Michaelis-Menten and linear regression models.
* Computes R-squared values to assess model fit and selects the better-performing model.
* Handles exceptions by defaulting to a linear model and logs warnings if necessary.
* Returns a dictionary containing model results, plots, and predicted values.

## `_hill_function(x, alpha, gamma)`
### USAGE
* Static method to apply the Hill function transformation to a dataset.

### IMPL
* Computes the Hill function using the mathematical formula: `x^alpha / (x^alpha + gamma^alpha)`.
* This transformation is used in the feature engineering process to model certain types of relationships.

## `_prophet_decomposition(dt_mod: pd.DataFrame) -> pd.DataFrame`
### USAGE
* **dt_mod**: A pandas DataFrame representing the modulated data.
* Performs Prophet decomposition on the dataset and returns the transformed data with additional features.

### IMPL
* Configures and fits a Prophet model using available holiday and seasonal data.
* Incorporates custom parameters if available and manages multiple regressors.
* Logs warnings for known Prophet issues to prevent unexpected errors.
* Updates the dataset with trends, seasonalities, and holidays information.

## `_set_holidays(dt_transform: pd.DataFrame, dt_holidays: pd.DataFrame, interval_type: str) -> pd.DataFrame`
### USAGE
* **dt_transform**: A pandas DataFrame representing the transformed dataset.
* **dt_holidays**: A pandas DataFrame containing holiday data.
* **interval_type**: A string indicating the data interval type ("day", "week", or "month").
* Sets holidays in the dataset based on the specified interval type.

### IMPL
* Ensures date columns are in datetime format for consistency.
* Adjusts holidays according to the interval type and raises a `ValueError` for invalid types.
* Handles aggregation for weekly and monthly intervals to ensure accurate holiday representation.

## `_apply_transformations(x: pd.Series, params: ChannelHyperparameters) -> pd.Series`
### USAGE
* **x**: A pandas Series representing the data to be transformed.
* **params**: An instance of `ChannelHyperparameters` that contains transformation parameters.
* Applies adstock and saturation transformations to the given series.

### IMPL
* Calls `_apply_adstock()` and `_apply_saturation()` to perform the necessary transformations.
* Returns the transformed series for further analysis or modeling.

## `_apply_adstock(x: pd.Series, params: ChannelHyperparameters) -> pd.Series`
### USAGE
* **x**: A pandas Series representing the data to be adstocked.
* **params**: An instance of `ChannelHyperparameters` containing adstock parameters.
* Applies the specified adstock transformation to the given series.

### IMPL
* Selects the appropriate adstock function based on the hyperparameter type.
* Supports both geometric and Weibull adstock types.
* Raises a `ValueError` for unsupported adstock types to ensure proper error handling.

## `_geometric_adstock(x: pd.Series, theta: float) -> pd.Series`
### USAGE
* Static method to apply geometric adstock transformation to a dataset.

### IMPL
* Utilizes an exponential weighted moving average with a specified `theta`.
* Computes the geometric adstocked series for the provided data.

## `_weibull_adstock(x: pd.Series, shape: float, scale: float) -> pd.Series`
### USAGE
* Static method to apply Weibull adstock transformation.

### IMPL
* Computes the Weibull probability density function to generate weights for the transformation.
* Convolves the weights with the input series to produce the adstocked series, capturing delayed effects.

## `_apply_saturation(x: pd.Series, params: ChannelHyperparameters) -> pd.Series`
### USAGE
* Static method to apply saturation transformation to a dataset.

### IMPL
* Computes the saturation transformation using a formula involving `alpha` and `gamma`.
* Returns the transformed series, modeling diminishing returns or saturation effects.
Loading
Loading