Skip to content

Commit f74190e

Browse files
authored
Implement multidimensional scaling approach in regular MMM (#1862)
* feat: implement multidimensional scaling approach in regular MMM This commit transforms the regular MMM to use the same scaling approach as the multidimensional MMM, where data is stored in original scale and scaling is applied within the model graph using PyTensor operations. Key Changes: - Add scaling configuration parameter to MMM constructor - Store original scale data in preprocessed_data instead of pre-scaling - Compute scale factors (target_scale, channel_scale) and store as pm.Data variables - Apply scaling transformations within the model graph - Fix sample_posterior_predictive to return original scale data by default - Update transformation logic throughout codebase to work with original scale data - Add original scale contribution variables (channel_contribution_original_scale, etc.) - Update channel_contribution_forward_pass to use computed scale factors - Preserve backward compatibility with existing transformer approach Fixes: - Resolves KeyError when accessing y_out_of_sample['y'] from sample_posterior_predictive - Ensures out-of-sample predictions return same scale as training data (original scale) - Fixes plotting methods to work correctly with original scale variables Tests: - 442/444 tests pass (2 implementation-specific tests marked as xfail) - Add fallback logic for backward compatibility - Update test expectations for new scaling behavior This change ensures consistency between regular MMM and multidimensional MMM scaling approaches while maintaining API compatibility. * pre-commit * changing a few things * Adding tests * Modifying to nc * Solve test issue
1 parent 492930a commit f74190e

File tree

7 files changed

+2866
-1811
lines changed

7 files changed

+2866
-1811
lines changed

docs/source/notebooks/mmm/mmm_allocation_assessment.ipynb

Lines changed: 53 additions & 55 deletions
Large diffs are not rendered by default.

docs/source/notebooks/mmm/mmm_causal_identification.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4152,7 +4152,7 @@
41524152
"name": "python",
41534153
"nbconvert_exporter": "python",
41544154
"pygments_lexer": "ipython3",
4155-
"version": "3.10.18"
4155+
"version": "3.12.11"
41564156
}
41574157
},
41584158
"nbformat": 4,

docs/source/notebooks/mmm/mmm_example.ipynb

Lines changed: 2400 additions & 1657 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)