validate_cost_per_target_rows#
- pymc_marketing.mmm.lift_test.validate_cost_per_target_rows(calibration_df, model, *, target_column='cost_per_target', get_indices=<function exact_row_indices>, likelihood=None)[source]#
Check a cost-per-target table and likelihood against model without touching the graph.
Shared by
add_cost_per_target_observations()andMMM.add_cost_per_target_calibrationso that a table is refused by one set of checks, before either of them changes the model.- Parameters:
calibration_df (
DataFrame) – One row per calibration value, with achannelcolumn, one column per non-date dim ofchannel_data, target_column andsigma.model (
Model) – The model whose coordinates the rows are mapped to.target_column (
str) – Column holding the calibration values.get_indices (
Callable[[DataFrame,Model],dict[str,Sequence[int] |NDArray[integer]]]) – Maps the dim columns of calibration_df to model coordinate indices.likelihood (
Prior|None) – Calibration likelihood;NonemeansPrior("Normal"). Seeadd_cost_per_target_observations()for the supported families.
- Return type:
tuple[Indices,np.ndarray,np.ndarray,Prior]- Returns:
The row indices per dim, the calibration values and their
sigmaas float arrays, and the resolved likelihood.- Raises:
TypeError – If likelihood is not a
Prior.KeyError – If a required column or dim column is missing.
UnalignedValuesError – If a
channelor dim label is not a model coordinate (with the default get_indices).ValueError – If likelihood sets any parameter other than
StudentT’snu,dims, atransformorcentered=False, is aStudentTwithoutnuor with anuthat carries dims or arrays, is a non-positive constant or a prior that can go negative, or is notNormal,StudentTorLogNormal; if target_column orsigmacannot be converted to finite float values; ifsigmais not strictly positive; or if a calibration value is not strictly positive underLogNormal.