新しく開設された
Discord コミュニティに参加して、リアルタイムのディスカッション、ユーザー同士のサポート、メリディアン チームとの直接の交流をお楽しみください。
モデルを実行する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
モデルを実行するときは、モデル仕様を追加してからコマンドを実行し、事前分布と事後分布をサンプリングします。
事後分布からのサンプリングには、マルコフ連鎖モンテカルロ(MCMC)アルゴリズムを使用します。Meridian では、ステップサイズとカーネルの適応を伴う No-U-Turn サンプリング法を使用します。
モデルを実行するには:
モデル仕様を追加します。
例:
model_spec = spec.ModelSpec(
prior=prior_distribution.PriorDistribution(),
media_effects_dist='log_normal',
hill_before_adstock=False,
max_lag=8,
unique_sigma_for_each_geo=False,
media_prior_type='roi',
roi_calibration_period=None,
rf_prior_type='coefficient',
rf_roi_calibration_period=None,
organic_media_prior_type='contribution',
organic_rf_prior_type='contribution',
non_media_treatments_prior_type='contribution',
knots=None,
baseline_geo=None,
holdout_id=None,
control_population_scaling_id=None,
)
次のコマンドを実行して、事前分布と事後分布からサンプリングします。必要に応じてパラメータを設定します。
meridian = model.Meridian(input_data=data, model_spec=model_spec)
meridian.sample_prior(500)
meridian.sample_posterior(n_chains=7, n_adapt=500, n_burnin=500, n_keep=1000)
パラメータ |
説明 |
n_chains |
同時にサンプリングするチェーンの数。メモリ消費量を削減するには、MCMC サンプリングの順次呼び出しを許可する整数のリストを使用します。リストが指定されている場合、シーケンス内の各要素は windowed_adaptive_nuts 呼び出しの n_chains 引数に対応します。 |
n_adapt |
ステップサイズとカーネルを適応させている間の、チェーンあたりの MCMC 抽出数。これらの抽出は常に除外されます。 |
n_burnin |
ステップサイズとカーネルが確定した後に除外される、チェーンあたりの追加の MCMC 抽出数。適応が完了した後にすべてのチェーンが定常分布に達するようにするために、こうした追加の抽出が必要となる場合があります。ただし実際には、適応中にチェーンが定常分布に達し、n_burnin=0 で十分だったということはよくあります。 |
n_keep |
モデルの分析と結果のために保持する、チェーンあたりの MCMC 抽出数。 |
次にモデリング診断を行い、収束を評価し、分布を確認して、モデルの適合度を評価します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-04 UTC。
[null,null,["最終更新日 2025-08-04 UTC。"],[[["\u003cp\u003eThe model requires a defined model specification, which includes parameters like prior distribution, media effects, and other configurations.\u003c/p\u003e\n"],["\u003cp\u003eTo run the model, you first define the model specification and then use the \u003ccode\u003emeridian\u003c/code\u003e object to sample from both the prior and posterior distributions.\u003c/p\u003e\n"],["\u003cp\u003eMarkov Chain Monte Carlo (MCMC) methods are used for sampling from the posterior distribution, utilizing the No-U-Turn sampling method with step size and kernel adaptation.\u003c/p\u003e\n"],["\u003cp\u003eParameters like \u003ccode\u003en_chains\u003c/code\u003e, \u003ccode\u003en_adapt\u003c/code\u003e, \u003ccode\u003en_burnin\u003c/code\u003e, and \u003ccode\u003en_keep\u003c/code\u003e control the MCMC sampling process, determining the number of parallel chains, adaptation draws, burn-in draws, and draws to keep.\u003c/p\u003e\n"]]],["The process involves specifying a model using `ModelSpec`, defining parameters like prior distributions, media effects, and lag. Then, use the `Meridian` class to run the model by sampling from prior and posterior distributions. The posterior sampling employs the No-U-Turn algorithm with step size and kernel adaptation, and requires parameter configuration like `n_chains`, `n_adapt`, `n_burnin`, and `n_keep` to control the Markov Chain Monte Carlo draws. After sampling, you run model diagnostics to assess the quality of the results.\n"],null,["# Run the model\n\nWhen you run the model, you add your model specification, and then run the\ncommands to sample the prior distribution and the posterior distribution.\n\nMarkov Chain Monte Carlo (MCMC) algorithms are used to sample from the posterior\ndistribution. Meridian uses the\n[No-U-Turn](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/mcmc/windowed_adaptive_nuts)\nsampling method with step size and kernel adaptation.\n\nTo run the model:\n\n1. Add your model specification.\n\n **Example:** \n\n model_spec = spec.ModelSpec(\n prior=prior_distribution.PriorDistribution(),\n media_effects_dist='log_normal',\n hill_before_adstock=False,\n max_lag=8,\n unique_sigma_for_each_geo=False,\n media_prior_type='roi',\n roi_calibration_period=None,\n rf_prior_type='coefficient',\n rf_roi_calibration_period=None,\n organic_media_prior_type='contribution',\n organic_rf_prior_type='contribution',\n non_media_treatments_prior_type='contribution',\n knots=None,\n baseline_geo=None,\n holdout_id=None,\n control_population_scaling_id=None,\n )\n\n2. Run the following commands to sample from the prior and posterior\n distribution. Configure the parameters as needed:\n\n meridian = model.Meridian(input_data=data, model_spec=model_spec)\n meridian.sample_prior(500)\n meridian.sample_posterior(n_chains=7, n_adapt=500, n_burnin=500, n_keep=1000)\n\n | Parameter | Description |\n |------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | `n_chains` | The number of chains to be sampled in parallel. To reduce memory consumption, you can use a list of integers to allow for sequential MCMC sampling calls. Given a list, each element in the sequence corresponds to the `n_chains` argument for a call to `windowed_adaptive_nuts`. |\n | `n_adapt` | The number of MCMC draws per chain, during which step size and kernel are adapted. These draws are always excluded. |\n | `n_burnin` | An additional number of MCMC draws, per chain, to be excluded after the step size and kernel are fixed. These additional draws may be needed to ensure that all chains reach the stationary distribution after adaptation is completed, but in practice we often find that the chains reach the stationary distribution during adaptation and that `n_burnin=0` is sufficient. |\n | `n_keep` | The number of MCMC draws, per chain, to keep for the model analysis and results. |\n\nNext, run modeling diagnostics to [assess convergence, check the distributions,\nand assess the model fit](/meridian/docs/user-guide/model-diagnostics)."]]