to_mmm_dataset#

pymc_marketing.mmm.data_conversion.to_mmm_dataset(X, y=None, *, date_column, dims=(), channel_columns, control_columns=None, target_column=None)[source]#

Normalise X (and optionally y) to a single canonical xr.Dataset.

This is the sole entry point for data normalisation in the MMM pipeline. It handles all supported input type combinations and returns a dataset with the canonical underscore-prefixed variable names (_channel, _target, _control).

Parameters:
X

Feature data.

y

Target variable. When X is already an xr.Dataset that contains a target / _target data variable this may be omitted.

date_column

Name of the date column in a pd.DataFrame input.

dims

Extra dimension names (e.g. ("geo",)).

channel_columns

Names of the media-channel columns.

control_columns

Names of control-variable columns.

target_column

Name of the target / response variable.

Returns:
xr.Dataset

Dataset with variables _channel, (optional) _target, and (optional) _control and coordinates for each dimension.