helpers#

Shared computation helpers for MMM summary factories.

Functions

compute_channel_shares(channel_contributions)

Compute each channel's share of total channel contribution.

compute_residuals(data)

Compute residuals as target minus posterior predictions.

compute_summary_stats_with_hdi(data, hdi_probs)

Module-level wrapper around StatsHelper.compute_summary_stats_with_hdi().

compute_waterfall_components(data[, dims, ...])

Mean contributions over date per component for waterfall summaries.

convert_output(df[, output_format])

Module-level wrapper around StatsHelper.convert_output().

dataframe_to_json_records(df)

Convert a summary DataFrame to JSON-serializable records.

get_channel_x_data(data, apply_cost_per_unit)

Return channel spend or raw channel data based on cost-per-unit flag.

get_prior_for_plot(data, original_scale)

Return the correct idata group for prior predictive plotting.

prepare_sensitivity_data(sa_da, data[, ...])

Prepare sensitivity data for summary tables (steps 1-5 of sensitivity plots).

Classes

StatsHelper()

Lightweight helper for HDI summary stats and output conversion.