causaldemand 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. causaldemand-1.0.0/LICENSE +202 -0
  2. causaldemand-1.0.0/MANIFEST.in +2 -0
  3. causaldemand-1.0.0/PKG-INFO +297 -0
  4. causaldemand-1.0.0/README.md +254 -0
  5. causaldemand-1.0.0/causaldemand/__init__.py +44 -0
  6. causaldemand-1.0.0/causaldemand/__main__.py +5 -0
  7. causaldemand-1.0.0/causaldemand/_code.py +73 -0
  8. causaldemand-1.0.0/causaldemand/_generator_step.py +40 -0
  9. causaldemand-1.0.0/causaldemand/cli.py +384 -0
  10. causaldemand-1.0.0/causaldemand/download.py +192 -0
  11. causaldemand-1.0.0/causaldemand/generate.py +426 -0
  12. causaldemand-1.0.0/causaldemand/names.py +179 -0
  13. causaldemand-1.0.0/causaldemand/rescore.py +481 -0
  14. causaldemand-1.0.0/causaldemand/scoring.py +88 -0
  15. causaldemand-1.0.0/causaldemand/sources.py +142 -0
  16. causaldemand-1.0.0/causaldemand.egg-info/PKG-INFO +297 -0
  17. causaldemand-1.0.0/causaldemand.egg-info/SOURCES.txt +34 -0
  18. causaldemand-1.0.0/causaldemand.egg-info/dependency_links.txt +1 -0
  19. causaldemand-1.0.0/causaldemand.egg-info/entry_points.txt +2 -0
  20. causaldemand-1.0.0/causaldemand.egg-info/requires.txt +22 -0
  21. causaldemand-1.0.0/causaldemand.egg-info/top_level.txt +1 -0
  22. causaldemand-1.0.0/metrics/__init__.py +8 -0
  23. causaldemand-1.0.0/metrics/conftest.py +7 -0
  24. causaldemand-1.0.0/metrics/elasticity.py +461 -0
  25. causaldemand-1.0.0/metrics/panel_scorer.py +297 -0
  26. causaldemand-1.0.0/metrics/test_elasticity.py +404 -0
  27. causaldemand-1.0.0/metrics/test_panel_scorer.py +171 -0
  28. causaldemand-1.0.0/packaging/build_public_tree.py +442 -0
  29. causaldemand-1.0.0/packaging/package_release.py +1197 -0
  30. causaldemand-1.0.0/packaging/release_runs.py +573 -0
  31. causaldemand-1.0.0/packaging/release_spec.yaml +933 -0
  32. causaldemand-1.0.0/pyproject.toml +86 -0
  33. causaldemand-1.0.0/setup.cfg +4 -0
  34. causaldemand-1.0.0/tests/conftest.py +83 -0
  35. causaldemand-1.0.0/tests/test_options.py +239 -0
  36. causaldemand-1.0.0/tests/test_release.py +241 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ # Files of the source distribution beyond the packages (setuptools adds the README, the license and tests/test*.py).
2
+ include tests/conftest.py
@@ -0,0 +1,297 @@
1
+ Metadata-Version: 2.4
2
+ Name: causaldemand
3
+ Version: 1.0.0
4
+ Summary: CausalDemand: synthetic retail sales datasets for testing whether a method predicts how sales respond to price changes. Download, scoring and regeneration tools.
5
+ Author: Juwon Hong, Minha Hwang, Venkatesh Shankar
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/jean-jsj/CausalDemand
8
+ Project-URL: Repository, https://github.com/jean-jsj/CausalDemand
9
+ Project-URL: Dataset, https://huggingface.co/datasets/jean-jsj/CausalDemand
10
+ Keywords: benchmark,causal inference,counterfactual prediction,demand estimation,price elasticity,retail,synthetic data
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy>=1.24
25
+ Requires-Dist: pandas>=2.0
26
+ Requires-Dist: scipy>=1.13
27
+ Requires-Dist: pyarrow>=14
28
+ Requires-Dist: PyYAML>=6.0
29
+ Requires-Dist: huggingface_hub>=0.23
30
+ Provides-Extra: generate
31
+ Requires-Dist: numpy==1.24.3; python_version < "3.11" and extra == "generate"
32
+ Requires-Dist: pandas==2.3.3; python_version < "3.11" and extra == "generate"
33
+ Requires-Dist: scipy==1.13.1; python_version < "3.11" and extra == "generate"
34
+ Requires-Dist: statsmodels==0.14.6; python_version < "3.11" and extra == "generate"
35
+ Requires-Dist: pyarrow==21.0.0; python_version < "3.11" and extra == "generate"
36
+ Requires-Dist: PyYAML==6.0.3; python_version < "3.11" and extra == "generate"
37
+ Requires-Dist: scikit-learn==1.6.1; python_version < "3.11" and extra == "generate"
38
+ Requires-Dist: matplotlib==3.9.4; python_version < "3.11" and extra == "generate"
39
+ Requires-Dist: xlrd==2.0.2; python_version < "3.11" and extra == "generate"
40
+ Provides-Extra: test
41
+ Requires-Dist: pytest; extra == "test"
42
+ Dynamic: license-file
43
+
44
+ # CausalDemand
45
+
46
+ CausalDemand is a benchmark for methods that predict how retail sales respond to a change in price. It tests whether
47
+ a method that forecasts sales well also gets the effect of price right when prices are confounded: in half of the
48
+ datasets, stores deepen discounts when an unobserved demand shock is high, so deep discounts and high sales coincide
49
+ for a reason other than the discount, and a model that learns the price effect from this co-movement overstates it. A
50
+ held-out forecast cannot reveal the error, because the held-out weeks follow the same pricing. The generator records
51
+ every random quantity it draws, so it computes what sales would have been at prices that were never charged: in closed
52
+ form for the log-linear model, and for the discrete-choice model by averaging over 10,000 simulated shoppers per store
53
+ and week, the same shoppers at the actual and at the changed price.
54
+
55
+ The datasets are synthetic weekly sales of 40 facial-tissue products in 731 stores over 156 weeks, from a generator
56
+ calibrated on licensed store sales records. 20 further datasets repeat the design for a second product category,
57
+ yogurt.
58
+
59
+ | | |
60
+ |---|---|
61
+ | Datasets | Hugging Face: <https://huggingface.co/datasets/jean-jsj/CausalDemand> (DOI [10.57967/hf/10744](https://doi.org/10.57967/hf/10744)) |
62
+ | Code | this repository, release [v1.0](https://github.com/jean-jsj/CausalDemand/releases/tag/v1.0) |
63
+ | Paper | "CausalDemand: Benchmarking Causal Recovery of Demand from Retail Transactions and Product Text" (KDD 2027 Datasets and Benchmarks Track, submitted) |
64
+
65
+ ## Datasets
66
+
67
+ Each dataset is one **configuration**, a demand model with confounding off or on, generated with one of five seeds:
68
+ 2 demand models x 2 confounding settings x 5 seeds = 20 datasets, named `<configuration>_seed<NNN>`.
69
+
70
+ | Configuration | Demand model | Confounding | Seeds |
71
+ |---|---|---|---|
72
+ | `loglinear_confounding_off` | log-linear | off | 1, 10, 20, 30, 40 |
73
+ | `loglinear_confounding_on` | log-linear | on | 1, 10, 20, 30, 40 |
74
+ | `discretechoice_confounding_off` | discrete-choice | off | 1, 10, 20, 30, 40 |
75
+ | `discretechoice_confounding_on` | discrete-choice | on | 1, 10, 20, 30, 40 |
76
+
77
+ - **Log-linear model:** expected weekly units are a log-linear function of the product's regular price and discount,
78
+ the prices and discounts of the other products (more strongly for products that are closer in a product distance
79
+ computed from the product descriptions), and demand terms for product, brand, store, region and week.
80
+ - **Discrete-choice model:** in each store and week, simulated households decide whether to buy and which stocked
81
+ product to buy; their tastes are correlated more strongly across closer products.
82
+ - **Confounding on:** the discount of a promoted week responds to the unobserved demand shock (loading 0.30).
83
+ **Confounding off:** it does not. The two datasets of a demand model and seed are generated from the same random
84
+ draws and differ in the discounts of promoted weeks and in what follows from them.
85
+
86
+ 20 further **dose-response datasets** repeat the confounding-on configurations at confounding strengths 0.15 and 0.45.
87
+
88
+ 20 **yogurt datasets** repeat the four configurations and five seeds for a second product category: 100 yogurt
89
+ products in 721 stores over the same 156 weeks, generated by the same generator and calibrated on yogurt sales
90
+ records. Beyond that, they differ from the facial-tissue datasets in four main ways: the confounding strength with
91
+ confounding on is 0.42 (log-linear) and 0.36 (discrete-choice); the product distance is estimated from the products
92
+ between which households switch, not from product descriptions; the product table holds the pack size and catalogue
93
+ attributes instead of a description; and each market's seasonal pattern follows its own yogurt sales instead of
94
+ influenza activity. They are named `yogurt_<configuration>_seed<NNN>` and lie in `yogurt/` on Hugging Face, outside
95
+ the dataset subsets, with the predictions and run records of their reference-model runs in `runs/yogurt/`.
96
+ [`docs/DATA.md`](docs/DATA.md) describes every file and column (yogurt: Section 11).
97
+
98
+ ## Install
99
+
100
+ In a copy of this repository (Python 3.9 to 3.12 and 3.14 are tested):
101
+
102
+ ```
103
+ pip install .
104
+ ```
105
+
106
+ From PyPI: `pip install causaldemand`; from GitHub: `pip install git+https://github.com/jean-jsj/CausalDemand`. Either installs the `causaldemand` command and the scorer.
107
+ Regenerating datasets and running the reference models need their own environments ([`locks/README.md`](locks/README.md)).
108
+
109
+ ## Quickstart
110
+
111
+ Run the commands from the repository root. Every command that reads released files downloads them from Hugging
112
+ Face, or reads a local copy of the release with `--source <folder>`. An output folder that a command creates
113
+ (`causaldemand_data/`, `scores/` and so on) holds a `.gitignore` file, so git ignores it.
114
+
115
+ 1. **Download a dataset** with its ground truth (776 MB of CSV):
116
+
117
+ ```
118
+ causaldemand download loglinear_confounding_on_seed001 --ground-truth
119
+ ```
120
+
121
+ This writes `causaldemand_data/loglinear_confounding_on_seed001/`: `public/` holds the files a method may use
122
+ (training sales, the prices of the 16 evaluation weeks, the 32 counterfactual scenarios, products and stores),
123
+ `ground_truth/` the expected units the scores compare with.
124
+
125
+ 2. **Predict.** Fit a method on the 140 training weeks and write two files from the same fitted model:
126
+ `forecast.csv` (`product_id, store_id, week, predicted_units`, for every row of
127
+ `public/transactions_holdout_context_public.csv`) and `scenarios.csv` (`intervention_id, product_id, store_id,
128
+ week, predicted_delta_units`, the predicted change in units under each scenario, for every row of
129
+ `public/counterfactual_sweep_context_panel.csv` whose `intervention_price` differs from its `baseline_price`).
130
+ [`notebooks/quickstart.ipynb`](notebooks/quickstart.ipynb) writes both files for a trivial method in a few lines,
131
+ into `notebooks/quickstart/` (see [Notebooks](#notebooks) for how to run it).
132
+
133
+ 3. **Score** the two files, here those of the notebook:
134
+
135
+ ```
136
+ causaldemand score --dataset causaldemand_data/loglinear_confounding_on_seed001 --forecast notebooks/quickstart/forecast.csv --scenarios notebooks/quickstart/scenarios.csv --out scores
137
+ ```
138
+
139
+ For the trivial method of the notebook (each pair's mean weekly training units, no response to any price change):
140
+ forecast error 0.4625, counterfactual error 0.1384, mean absolute counterfactual bias 0.9934, share of scenarios
141
+ with an overstated response 0, status valid.
142
+
143
+ `causaldemand --help` lists every command (download, score, elasticity, rescore, generate).
144
+
145
+ ## Notebooks
146
+
147
+ - [`notebooks/quickstart.ipynb`](notebooks/quickstart.ipynb) runs steps 1 to 3 of the quickstart for a trivial
148
+ method.
149
+ - [`notebooks/full_run.ipynb`](notebooks/full_run.ipynb) runs a reference model of the paper (LightGBM) on the same
150
+ dataset, compares its scores with the released run, and rebuilds the default-settings table from the released
151
+ predictions. It runs the model with the CPU-model environment: create it as `.venv-models` in the repository root
152
+ ([`locks/README.md`](locks/README.md); on macOS, LightGBM also needs the OpenMP runtime `libomp`), or set the
153
+ environment variable `CAUSALDEMAND_MODEL_PYTHON` to the Python of that environment.
154
+
155
+ Both read the dataset from `causaldemand_data/` (step 1), downloading it there if it is missing, and write their
156
+ output into `notebooks/quickstart/` and `notebooks/full_run/`. To read a local copy of the release instead of Hugging
157
+ Face, set the environment variable `CAUSALDEMAND_SOURCE` to its folder. The package does not install Jupyter; to run
158
+ a notebook from the command line, in the package environment:
159
+
160
+ ```
161
+ pip install nbconvert ipykernel
162
+ jupyter nbconvert --to notebook --execute --output-dir notebooks/executed notebooks/quickstart.ipynb
163
+ ```
164
+
165
+ This writes the executed copy to `notebooks/executed/`. The quickstart takes about 15 seconds plus the download,
166
+ `full_run.ipynb` about 2 minutes.
167
+
168
+ ## Reproduce the paper
169
+
170
+ From the repository root:
171
+
172
+ ```
173
+ causaldemand rescore --out rescored --compare-with results
174
+ ```
175
+
176
+ This re-scores the released predictions of 560 reference-model runs on the facial-tissue datasets (280 CPU runs and
177
+ 280 foundation-model runs) and compares every score with the archived one in `results/` (about 3 minutes, plus a
178
+ download of about 1.8 GB). The 320 runs on the yogurt datasets (CPU and foundation models) are re-scored with
179
+ `causaldemand rescore --runs yogurt --out rescored --compare-with results` (about 3.5 minutes, plus a download of about
180
+ 2.3 GB). [`docs/REPRODUCE.md`](docs/REPRODUCE.md) gives four tiers:
181
+ rescoring the released predictions, rerunning the CPU models, regenerating a dataset from the calibration bundle, and
182
+ rerunning the foundation models on a GPU.
183
+
184
+ ## Tasks and scores
185
+
186
+ A method is fitted on the 140-week training window of a dataset, using only that dataset's input files, and evaluated
187
+ on the following 16 weeks in two tasks.
188
+
189
+ - **Sales forecasting:** predict the units `q̂` of every product-store-week of the evaluation file at the actual
190
+ prices. Score: the **forecast error** `Σ |q̂ - q| / Σ q`, where `q` are the true expected units.
191
+ - **Counterfactual prediction:** predict how these units change if the price of one product or one brand is raised or
192
+ lowered by 10% through its promotion discount (32 scenarios: the top 12 products and the top 4 brands, each +10% and
193
+ -10%). On the rows `R` where a scenario changes a target's price, the predicted percentage change is applied to the
194
+ true units, `q̃_cf = q (1 + Δq̂ / q̂)`, so that an error in the sales level cannot offset an error in the response:
195
+ - **counterfactual error** `= Σ_R |q̃_cf - q_cf| / Σ_R q_cf`;
196
+ - **counterfactual bias** `= Σ_R (q̃_cf - q_cf) / Σ_R |q_cf - q|` (a method that overstates the effect of price has a
197
+ negative bias after a price increase and a positive bias after a decrease).
198
+
199
+ The headline score is the mean counterfactual error over the 32 scenarios; the mean absolute bias and the share of
200
+ scenarios with an overstated response describe the direction of the errors. Methods are ranked by the mean
201
+ counterfactual error on the confounding-on configurations, separately for each demand model, and scores are reported as
202
+ means over the five seeds with 95% t-intervals. A score is valid only if every ground-truth row has a prediction, no
203
+ row is excluded, all 32 scenarios are scored, no key repeats in the forecast file and the scores are finite. A method
204
+ may also submit its 40 x 40 table of elasticities, which is compared with the true table and reported, not ranked
205
+ (`causaldemand elasticity`). [`docs/SUBMISSION.md`](docs/SUBMISSION.md) gives the exact rules.
206
+
207
+ ## Before you use the results
208
+
209
+ - **Rounding floor.** Prices paid are rounded to end in 9 cents, while demand responds to the unrounded price. A
210
+ reference that knows the true demand but reads the scenario file's price change at face value scores a
211
+ counterfactual error of 0.038 to 0.042 (mean over seeds per configuration). These reference rows are in
212
+ [`results/main/reference_rows/`](results/main/reference_rows/README.md).
213
+ - **Pseudonyms can be decoded by inference.** Brands, markets, chains and manufacturers are replaced by codes, and
214
+ product and store identifiers by numbers, but the codes keep the order of the real labels (so that regeneration
215
+ reproduces the data exactly) and the released sales and public influenza data reveal more. Many codes can be
216
+ matched to a real market, chain, brand, manufacturer, product or store ([`docs/DATASHEET.md`](docs/DATASHEET.md)).
217
+ - **Reference models fill the seasonal index of the evaluation weeks with 1.0**, a high-season value on the
218
+ discrete-choice index. The archived results keep it. Filling the training-window mean instead changes one examined
219
+ run's counterfactual error by 0.002 and its forecast error by 0.013; the five-seed counterfactual error of that
220
+ configuration does not change at three decimals ([`docs/EXPERIMENT_RULES.md`](docs/EXPERIMENT_RULES.md), Section 4.4).
221
+ - **The elasticity diagnostic** (Appendix F.4 of the paper) is supplementary. The true table describes a change of the
222
+ regular price; the log-linear cross elasticities count a competitor only where it is stocked
223
+ ([`docs/DATA.md`](docs/DATA.md), Section 4.4).
224
+ - **Foundation-model runs made again.** The predictions of the original foundation-model runs on the facial-tissue
225
+ datasets were not kept, so the runs of the main experiment and of the confounding strengths 0.15 and 0.45 were made
226
+ again on 2026-10-03 with the original settings. Their predictions and run records are released, and the scores in
227
+ `results/` are theirs. The foundation-model entries of the main results table and of the confounding-strength table
228
+ at each strength are unchanged at three decimals. A run repeated on the GPU model of the original run gave the same
229
+ scores; on another GPU model the counterfactual and forecast errors of single runs differ by at most 0.0017 (GPU
230
+ rounding; [`results/README.md`](results/README.md)).
231
+ - **Not released:** the licensed store sales records and store profiles the generator was calibrated on; the datasets
232
+ and predictions of the household-switching robustness check (its scores are in `results/`); the pipeline that wrote
233
+ the product descriptions and computed the product distances (both are released as files); the code and runs of the
234
+ paper's real-data check.
235
+ - **Yogurt.** The 20 yogurt datasets, their ground truth and the predictions and run records of the 320 yogurt runs
236
+ (100 CPU runs with default settings, 80 forecast-tuned CPU runs and 140 foundation-model runs) are released as files.
237
+ The licensed yogurt sales records, product dictionary and household purchase panel they rest on, and the code that
238
+ computed their product distance, are not released; no calibration bundle is given for them, so they cannot be
239
+ regenerated. Their product, store, brand, chain and manufacturer codes are numbered separately from those of the
240
+ facial-tissue datasets; only the market codes are shared. All 20 fail the generator's seasonal-swing check (a swing
241
+ of 0.016 to 0.044 against the band 0.057 ± 0.01) and are released as generated ([`docs/DATA.md`](docs/DATA.md),
242
+ Section 11).
243
+
244
+ ## Documentation
245
+
246
+ | Document | Contents |
247
+ |---|---|
248
+ | [`docs/DATA.md`](docs/DATA.md) | Every file, column and key of the datasets, the runs and the generator inputs |
249
+ | [`docs/SUBMISSION.md`](docs/SUBMISSION.md) | Prediction formats, what a method may use, validity, scores, reporting |
250
+ | [`docs/REPRODUCE.md`](docs/REPRODUCE.md) | Four tiers: rescore the released predictions, rerun the CPU models, regenerate a dataset, rerun the foundation models |
251
+ | [`docs/EXPERIMENT_RULES.md`](docs/EXPERIMENT_RULES.md) | The protocol behind the reference results: scenarios, scores, models and settings |
252
+ | [`docs/DATASHEET.md`](docs/DATASHEET.md) | Datasheet: motivation, composition, collection, uses, distribution, maintenance |
253
+ | [`locks/README.md`](locks/README.md) | Hash-checked environments for the generator, the CPU models and the foundation models |
254
+
255
+ ## Repository
256
+
257
+ | Folder | Contents |
258
+ |---|---|
259
+ | [`causaldemand/`](causaldemand) | The `causaldemand` command: download, score, elasticity, rescore, generate |
260
+ | [`metrics/`](metrics/README.md) | The scorer (`panel_scorer.py`) and the elasticity diagnostic (`elasticity.py`) |
261
+ | [`generator/`](generator/README.md) | The data generator, the counterfactual scenarios and the ground truth |
262
+ | [`config/`](config/README.md) | One configuration per dataset |
263
+ | `inputs/` | Generator inputs: the [calibration bundle](inputs/calibration_bundle/README.md), the [product descriptions and distances](inputs/product_distances/README.md), the [CDC influenza curves](inputs/cdc-ili/README.md) |
264
+ | [`packaging/`](packaging/README.md) | Turns generator output into the released files |
265
+ | [`models/`](models/README.md) | The reference models of the paper, as the code of the archived runs |
266
+ | [`experiments/`](experiments/README.md) | The scripts behind every result of the paper |
267
+ | [`results/`](results/README.md) | Scores of the paper's reference-model runs on the synthetic datasets (facial tissue and yogurt), with run records except for the household-switching runs |
268
+ | [`notebooks/`](notebooks) | `quickstart.ipynb` and `full_run.ipynb` ([Notebooks](#notebooks)) |
269
+ | `tests/` | Tests of the package; with `metrics/`, the default pytest run of the repository |
270
+
271
+ ## License and citation
272
+
273
+ Code: Apache License 2.0 ([`LICENSE`](LICENSE)). Data: CC BY 4.0 ([`DATA_LICENSE.md`](DATA_LICENSE.md)), which also
274
+ lists the sources and their terms. To cite, use [`CITATION.cff`](CITATION.cff): the paper, and the datasets by their
275
+ DOI:
276
+
277
+ ```bibtex
278
+ @inproceedings{hong2027causaldemand,
279
+ title = {CausalDemand: Benchmarking Causal Recovery of Demand from Retail Transactions and Product Text},
280
+ author = {Hong, Juwon and Hwang, Minha and Shankar, Venkatesh},
281
+ booktitle = {Proceedings of the ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD 2027), Datasets and Benchmarks Track},
282
+ year = {2027},
283
+ note = {Submitted}
284
+ }
285
+
286
+ @misc{hong2026causaldemanddata,
287
+ title = {CausalDemand},
288
+ author = {Hong, Juwon and Hwang, Minha and Shankar, Venkatesh},
289
+ year = {2026},
290
+ publisher = {Hugging Face},
291
+ doi = {10.57967/hf/10744},
292
+ url = {https://huggingface.co/datasets/jean-jsj/CausalDemand},
293
+ note = {Datasets, version 1.0.0 (Hugging Face revision 3b0a380)}
294
+ }
295
+ ```
296
+
297
+ The first author maintains the benchmark; questions and problems go to the GitHub issues of this repository.