モデルを実行する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
モデルを実行するときは、モデル仕様を追加してからコマンドを実行し、事前分布と事後分布をサンプリングします。
事後分布からのサンプリングには、マルコフ連鎖モンテカルロ(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-06-17 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-06-17 UTC。"],[[["The model requires a defined model specification, which includes parameters like prior distribution, media effects, and other configurations."],["To run the model, you first define the model specification and then use the `meridian` object to sample from both the prior and posterior distributions."],["Markov 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."],["Parameters like `n_chains`, `n_adapt`, `n_burnin`, and `n_keep` control the MCMC sampling process, determining the number of parallel chains, adaptation draws, burn-in draws, and draws to keep."]]],["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"]]