fix(mmm): allow constant tensors in adstock sample_prior (fixes #1749)#2304
fix(mmm): allow constant tensors in adstock sample_prior (fixes #1749)#2304shivamlalakiya wants to merge 10 commits into
Conversation
PR SummaryLow Risk Overview Adds regression tests for issue #1749 verifying Written by Cursor Bugbot for commit c940cf4. This will update automatically on new commits. Configure here. |
|
There's not really any prior being sampled... |
|
@ricardoV94 You're right — no actual sampling is happening here. The goal was to unblock the plot curve workflow from #1749 which needs an InferenceData to proceed. Would you prefer a different approach? For example, wrapping constants in pm.DiracDelta, emitting a warnings.warn to be explicit, or something else entirely? Happy to rework it based on your guidance. |
|
I was being just pedantic. It makes sense to support |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2304 +/- ##
==========================================
- Coverage 93.14% 93.13% -0.02%
==========================================
Files 80 80
Lines 12831 12846 +15
==========================================
+ Hits 11952 11964 +12
- Misses 879 882 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
340cdfc to
f504759
Compare
- Revert budget optimizer expected values (54.78/45.21) for default/minimal cases - Fix Fourier prior assertion: prior.dims is None (not empty tuple) - Fix XTensorVariable reshape: use pt.reshape on .values, only flatten when extracting optimizer's response_variable to preserve channel_data shape
- Remove flattening from extract_response_distribution in budget_optimizer - Update _check_samples_dimensionality to accept ndim >= 1 - Add _to_1d_samples for built-in risk/quantile utilities that need 1D - Custom utilities (e.g. mmm_multi_objective_optimization) now receive full (sample, channel, date) tensor for .sum(dim=(...)) logic
|
@williambdean All tests and CI checks are now passing!
Let me know if you need any adjustments or if this is good for a final review! |
Description
Fixes #1749
Previously,
sample_priorwould fail if an adstock transformation (e.g.,GeometricAdstock) was initialized with constant tensors instead of PyMC distributions, aspm.sample_prior_predictiverequires free random variables.This PR adds a fallback mechanism: if no free random variables are detected in the model, it evaluates the constant tensors deterministically and returns a valid
InferenceDataobject.Changes
sample_priorintransformers.pyto handleValueErrorfromsample_prior_predictive.tests/mmm/test_issue_1749.pyto verify constant inputs work.Related Issue
Checklist
pre-commit.ci autofixto auto-fix.📚 Documentation preview 📚: https://pymc-marketing--2304.org.readthedocs.build/en/2304/