pytyche.analysis.analyze

pytyche.analysis.analyze(data, *, max_depth=3, min_segment_share=0.1, n_bootstrap=50, bootstrap_seed=0)[source]

Fit-if-needed, then assemble the canonical analysis output.

Dispatches on the type of data:

  • ObservedExperimentData — the one-shot path: pt.fit(data) with fit defaults (customize the fit by calling fit() explicitly), then .analyze(**kwargs) on the fitted posterior.

  • A posterior result type — delegates to data.analyze(**kwargs) directly.

Keyword arguments are the embedded policy tree’s hyperparameters and are forwarded to .analyze in both branches; none reach the fit.

Parameters:
  • data (ObservedExperimentData | HurdleBCFResult | ContinuousBCFResult | BinaryBCFResult) – Observed experiment data, or one of the three posterior result types.

  • max_depth (int) – Embedded policy tree depth (forwarded).

  • min_segment_share (float) – Minimum per-leaf population share (forwarded).

  • n_bootstrap (int) – Stability bootstrap count (forwarded; 0 skips stability with a UserWarning).

  • bootstrap_seed (int) – Stability bootstrap seed (forwarded).

Return type:

AnalysisResult

Returns:

AnalysisResult — the SUMMARY surface; anything needing posterior samples goes through analysis.posterior.

Raises:
  • TypeError – When data is neither observed data nor a posterior result type.

  • ValueError – When a posterior data carries no observed data.