Skip to content

Commit 78ce886

Browse files
riemanliThe Meridian Authors
authored andcommitted
Adds a new check to the SamplingEDAEngine to analyze prior probabilities.
PiperOrigin-RevId: 871966810
1 parent 23d8ecc commit 78ce886

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

meridian/analysis/analyzer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ def __init__(
933933
# Make the meridian object ready for methods in this analyzer that create
934934
# backend.function computation graphs: it should be frozen for no more
935935
# internal states mutation before those graphs execute.
936-
self.model_context = _get_model_context(meridian, model_context)
936+
self._model_context = _get_model_context(meridian, model_context)
937937

938938
if meridian is not None:
939939
self._inference_data = inference_data or meridian.inference_data
@@ -945,7 +945,11 @@ def __init__(
945945
else:
946946
self._inference_data = inference_data
947947

948-
self.model_context.populate_cached_properties()
948+
self._model_context.populate_cached_properties()
949+
950+
@property
951+
def model_context(self) -> context.ModelContext:
952+
return self._model_context
949953

950954
@functools.cached_property
951955
def _model_equations(self) -> equations.ModelEquations:

meridian/analysis/analyzer_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,16 @@ def setUpClass(cls):
13241324
inference_data=cls.inference_data,
13251325
)
13261326

1327+
def test_init_populates_cached_properties(self):
1328+
with mock.patch.object(
1329+
context.ModelContext, "populate_cached_properties"
1330+
) as mock_populate:
1331+
analyzer.Analyzer(
1332+
model_context=self.meridian.model_context,
1333+
inference_data=self.inference_data,
1334+
)
1335+
mock_populate.assert_called_once()
1336+
13271337
def test_use_kpi_direct_calls_non_revenue_with_revenue_per_kpi(self):
13281338
# `use_kpi` is respected
13291339
with warnings.catch_warnings(record=True) as w:

meridian/model/eda/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@
324324
' positive correlation with population. If there is low or negative'
325325
' correlation, please check your data input.'
326326
)
327+
PRIOR_PROBABILITY_INFO = (
328+
'Negative baseline is equivalent to the treatment effects getting too much'
329+
' credit. Please review the prior probability of negative baseline together'
330+
' with the channel-level prior mean of contribution. If the prior'
331+
' probability of negative baseline is high, consider custom treatment'
332+
' priors. In particular, a custom `contribution prior` type may be'
333+
' appropriate.'
334+
)
327335
PRIOR_PROBABILITY_REPORT_INFO = (
328336
'Negative baseline is equivalent to the treatment effects getting too much'
329337
' credit. Please review the prior probability of negative baseline together'

0 commit comments

Comments
 (0)