加入新推出的
Discord 社区,展开实时讨论,获得同行支持,并直接与 Meridian 团队互动!
在效果不是收入时设置自定义先验
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Meridian 将投资回报率 (ROI) 定义为增量效果除以支出。如果 KPI 不是收入,并且 revenue_per_kpi
未传递到 InputData
,则效果不以收入为衡量标准。这可能会使确定自定义投资回报率先验变得困难。
如果效果不是收入,在设置自定义先验时,请考虑以下选项:
如果您对因付费媒体而增加的 KPI 总比例有直观了解,则可以针对所有渠道设置一个共同的投资回报率先验,从而定义具体媒体总贡献率的先验平均值和标准差,具体操作如下:
p_mean = 0.5 # prior mean proportion of KPI incremental due to all media
p_sd = 0.15 # prior std dev proportion of KPI incremental to all media
roi_mean = p_mean * kpi / np.sum(cost)
roi_sd = p_sd * kpi / np.sqrt(np.sum(np.power(cost, 2)))
lognormal_sigma = np.sqrt(np.log(roi_sd**2 / roi_mean**2 + 1))
lognormal_mu = np.log(roi_mean * np.exp(-lognormal_sigma**2 / 2))
roi_prior = tfp.distributions.LogNormal(
lognormal_mu.astype(np.float32),
lognormal_sigma.astype(np.float32),
)
其中:
kpi
是所有地理位置和时间段的所有 KPI 的总和。
cost
是一个数组,包含每个渠道在不同地理位置和时间段的总费用。
在此示例中,所有媒体的 KPI 贡献率以 50% 为中心,标准差为 15%。这样就得到了一个在所有渠道中都一致的投资回报率先验,即付费媒体总贡献率的隐含先验平均值为 50%,标准差为 15%。然后,可以通过在 roi_m
或 roi_rf
的 PriorDistribution
容器中设置派生先验 roi_prior
来使用该先验。
付费媒体总贡献率先验的优势在于,它不需要对每个渠道都有直观了解。不过,如果您有关于每个渠道的额外信息,或对每个渠道有直观了解,不妨考虑设置 IKPC 先验或渠道级贡献率先验。
自定义单位费用增量 KPI (IKPC) 先验
如果您对渠道的单位费用增量 KPI (IKPC) 有直观了解,可以在 PriorDistribution
容器中使用 roi_m
或 roi_rf
设置 IKPC 先验。如果未设置 revenue_per_kpi
,则投资回报率相当于 Meridian 中的 IKPC。
示例:
roi_prior = tfp.distributions.LogNormal([0.5, 0.6, 0.7], [0.5, 0.5, 0.5])
不过,我们建议您仅在为每个媒体渠道设置自定义 IKPC 先验时才这样做。这是因为,当 revenue_per_kpi=None
时,默认投资回报率先验很可能对您的数据没有意义,原因是它专门用于收入 KPI,而收入 KPI 的投资回报率是无单位的。如果您只对某些渠道的 IKPC 有直观了解,则仍需为其他渠道设置一些合理的默认 IKPC 先验。Meridian 没有推荐的默认 IKPC 先验,因为 IKPC 与规模效应密切相关,例如新车和糖果的规模效应就不同。
渠道级贡献率先验
如果您对因给定渠道而增加的 KPI 比例有直观了解,可以为给定渠道的贡献率设置先验,方法是在 ModelSpec
中设置 media_prior_type='contribution'
和 rf_prior_type='contribution'
,并在 PriorDistribution
中自定义 contribution_m
和 contribution_rf
的先验分布。下面给出了一个示例。
prior = prior_distribution.PriorDistribution(
contribution_m=tfp.distributions.Beta([1, 5], [99, 95]),
contribution_rf=tfp.distribution.Beta(2, 98),
)
model_spec = spec.ModelSpec(
prior=prior,
media_prior_type="contribution",
rf_prior_type="contribution",
)
在此示例中,有两个媒体渠道。第一个分配了 Beta(1, 99) 贡献率先验,其平均值为 1%。第二个分配了 Beta(5, 95) 贡献率先验,其平均值为 5%。每个 R&F 渠道都分配了 Beta(2, 98) 贡献率先验,其平均值为 2%。(请注意,tfp.distribution.Beta(2, 98)
是一种标量分布,因此会广播到所有 R&F 渠道)。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-17。
[null,null,["最后更新时间 (UTC):2025-08-17。"],[[["\u003cp\u003eMeridian calculates ROI as incremental outcome divided by spend, and when the KPI is not revenue, the outcome is not in terms of revenue.\u003c/p\u003e\n"],["\u003cp\u003eWhen the outcome is not revenue, setting a custom prior is possible via three options: Custom total paid media contribution prior, Custom incremental KPI per cost (IKPC) prior, or Channel-level contribution prior.\u003c/p\u003e\n"],["\u003cp\u003eSetting a custom total paid media contribution prior allows users to define the proportion of the KPI that is incremental due to all paid media channels, using a mean and standard deviation.\u003c/p\u003e\n"],["\u003cp\u003eCustom IKPC priors are set using \u003ccode\u003eroi_m\u003c/code\u003e or \u003ccode\u003eroi_rf\u003c/code\u003e, but it is recommended to set them for all media channels because the default ROI priors may not be appropriate, and there is no recommended default IKPC prior from Meridian.\u003c/p\u003e\n"],["\u003cp\u003eSetting a channel-level contribution prior allows users to set a prior on the contribution of a given channel, again it is recommended to do this for every media channel because the default priors may not be appropriate, and there is no recommended default media contribution prior from Meridian.\u003c/p\u003e\n"]]],[],null,["# Set custom priors when outcome is not revenue\n\nMeridian defines ROI as incremental outcome divided by spend. When the KPI is\nnot revenue and `revenue_per_kpi` is not passed to `InputData`,\n[outcome](/meridian/docs/basics/glossary) is not in terms of\nrevenue. This can make it difficult to determine a custom ROI prior.\n\nConsider the following options when setting a custom prior when outcome is not\nrevenue:\n\n- [Custom total paid media contribution prior](#set-total-paid-media-contribution-prior)\n- [Custom incremental KPI per cost (IKPC) prior](#set-ikpc-prior)\n- [Channel-level contribution prior](#set-channel-contribution-prior)\n\nCustom total paid media contribution prior\n------------------------------------------\n\nIf you have intuition about the total proportion of the KPI that is incremental\ndue to paid media, you can set a common ROI prior on all channels such that the\ntotal media contribution specific prior mean and standard deviation by doing the\nfollowing: \n\n p_mean = 0.5 # prior mean proportion of KPI incremental due to all media\n p_sd = 0.15 # prior std dev proportion of KPI incremental to all media\n roi_mean = p_mean * kpi / np.sum(cost)\n roi_sd = p_sd * kpi / np.sqrt(np.sum(np.power(cost, 2)))\n lognormal_sigma = np.sqrt(np.log(roi_sd**2 / roi_mean**2 + 1))\n lognormal_mu = np.log(roi_mean * np.exp(-lognormal_sigma**2 / 2))\n roi_prior = tfp.distributions.LogNormal(\n lognormal_mu.astype(np.float32),\n lognormal_sigma.astype(np.float32),\n )\n\nWhere:\n\n- `kpi` is the sum of the entire KPI across geos and time.\n- `cost` is an array of the total cost per channel across geos and time.\n\nIn this example, the KPI contribution of all media is centered at 50% with a\nstandard deviation of 15%. You then get an ROI prior that is consistent for all\nchannels, such that the implied prior on the total paid media contribution has a\nmean at 50% and a standard deviation at 15%. The derived prior, `roi_prior`, can\nthen be used by setting it in the `PriorDistribution` container for `roi_m` or\n`roi_rf`.\n\nThe total paid media contribution prior can be advantageous as it doesn't\nrequire intuition on each individual channel. However, if additional knowledge\nor intuition about each channel is available, then consider setting a [IKPC\nprior](#set-ikpc-prior) or\n[channel-level contribution\nprior](#set-channel-contribution-prior).\n\nCustom incremental KPI per cost (IKPC) prior\n--------------------------------------------\n\nIf you have intuition about a channel's incremental KPI per cost (IKPC), you can\nset a IKPC prior using `roi_m` or `roi_rf` in the `PriorDistribution` container.\nWhen `revenue_per_kpi` is not set, ROI is equivalent to IKPC in\nMeridian.\n\n**Example:** \n\n roi_prior = tfp.distributions.LogNormal([0.5, 0.6, 0.7], [0.5, 0.5, 0.5])\n\nHowever, we only recommend doing this if you are going to set a custom IKPC\nprior for every media channel. This is because the default ROI priors with\n`revenue_per_kpi=None` likely won't make sense for your data as it designed for\nrevenue KPIs where the ROI would be on the unitless scale. If you only have\nintuition on the IKPC for some channels, you still must set some reasonable\ndefault IKPC prior for the other channels. Meridian doesn't have a\nrecommended default IKPC prior because IKPC is strongly dependent on the scale,\nfor example, a new car or a candy bar.\n\nChannel-level contribution prior\n--------------------------------\n\nIf you have intuition about the proportion of the KPI that is incremental due to\na given channel, you can set a prior on the contribution of a given\nchannel by setting `media_prior_type='contribution'` and\n`rf_prior_type='contribution'` in the `ModelSpec` and customizing the prior\ndistributions on `contribution_m` and `contribution_rf` in the\n`PriorDistribution`. The following is an example. \n\n prior = prior_distribution.PriorDistribution(\n contribution_m=tfp.distributions.Beta([1, 5], [99, 95]),\n contribution_rf=tfp.distribution.Beta(2, 98),\n )\n model_spec = spec.ModelSpec(\n prior=prior,\n media_prior_type=\"contribution\",\n rf_prior_type=\"contribution\",\n )\n\nIn this example, there are two media channels. The first is assigned a Beta(1,\n99) contribution prior, which has a mean of 1%. The second is assigned a Beta(5,\n95) contribution prior, which has a mean of 5%. The R\\&F channels are each\nassigned a contribution prior of Beta(2, 98), which has a mean of 2%. (Note that\n`tfp.distribution.Beta(2, 98)` is a scalar distribution, so it is broadcast to\nall R\\&F channels)."]]