meridian.data.nd_array_input_data_builder.NDArrayInputDataBuilder

Builds InputData from n-dimensional arrays.

Inherits From: InputDataBuilder

controls

frequency

geos

kpi

media

media_spend

media_time_coords

non_media_treatments

organic_frequency

organic_media

organic_reach

population

reach

revenue_per_kpi

rf_spend

time_coords

Methods

build

View source

Builds an InputData.

Constructs an InputData from constituent DataArrays given to this builder thus far after performing one final validation pass over all data arrays for consistency checks.

Returns
A validated InputData.

with_controls

View source

Reads controls data from a ndarray.

nd must be given with the shape: - (n_geos, n_time, n_controls) - (n_time, n_controls) or (1, n_time, n_controls) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the controls data from.
control_names The names of the control variables.

Returns
The NDArrayInputDataBuilder with the added controls data.

with_kpi

View source

Reads KPI data from a ndarray.

nd must be given with the shape: - (n_geos, n_time) - (n_time,) or (1, n_time) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the KPI data from.

Returns
The NDArrayInputDataBuilder with the added KPI data.

with_media

View source

Reads media and media spend data from the ndarrays.

m_nd must be given with the shape: - (n_geos, n_media_times, n_media_channels) - (n_media_times, n_media_channels) or (1, n_media_times, n_media_channels) for national model.

ms_nd must be given with the shape: - (n_geos, n_times, n_media_channels) - (n_times, n_media_channels) or (1, n_times, n_media_channels) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
m_nd The ndarray that contains dimensional media data.
ms_nd The ndarray that contains dimensional media spend data.
media_channels The names of the media channels.

Returns
The NDArrayInputDataBuilder with the added media and media spend data.

with_non_media_treatments

View source

Reads non-media treatments data from a ndarray.

nd must be given with the shape: - (n_geos, n_time, n_media_channels) - (n_time, n_media_channels) or (1, n_time, n_media_channels) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the non-media treatments data from.
non_media_channel_names The names of the non-media channels.

Returns
The NDArrayInputDataBuilder with the added non-media treatments data.

with_organic_media

View source

Reads organic media data from a ndarray.

nd must be given with the shape: - (n_geos, n_media_times, n_organic_media_channels) - (n_media_times, n_organic_media_channels) or (1, n_media_times, n_organic_media_channels) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the organic media data from.
organic_media_channels The names of the organic media channels.

Returns
The NDArrayInputDataBuilder with the added organic media data.

with_organic_reach

View source

Reads organic reach and organic frequency data from the ndarrays.

or_nd and of_nd must be given with the shape: - (n_geos, n_media_times, n_organic_rf_channels) - (n_media_times, n_organic_rf_channels) or (1, n_media_times, n_organic_rf_channels) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
or_nd The ndarray that contains dimensional reach data.
of_nd The ndarray that contains dimensional frequency data.
organic_rf_channels The names of the organic rf channels.

Returns
The NDArrayInputDataBuilder with the added organic reach and organic frequency data.

with_population

View source

Reads population data from a ndarray.

nd must be given with the shape: - (n_geos,)

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the population data from.

Returns
The NDArrayInputDataBuilder with the added population data.

with_reach

View source

Reads reach, frequency, and rf_spend data from the ndarrays.

r_nd and f_nd must be given with the shape: - (n_geos, n_media_times, n_rf_channels) - (n_media_times, n_rf_channels) or (1, n_media_times, n_rf_channels) for national model.

rfs_nd must be given with the shape: - (n_geos, n_times, n_rf_channels) - (n_times, n_rf_channels) or (1, n_times, n_rf_channels) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
r_nd The ndarray that contains dimensional reach data.
f_nd The ndarray that contains dimensional frequency data.
rfs_nd The ndarray that contains dimensional rf_spend data.
rf_channels The names of the rf channels.

Returns
The NDArrayInputDataBuilder with the added reach, frequency, and rf_spend data.

with_revenue_per_kpi

View source

Reads Revenue per KPI data from a ndarray.

nd must be given with the shape: - (n_geos, n_time) - (n_time,) or (1, n_time) for national model.

If called without a call to .geos() first, the data will be assumed to be national-level.

Args
nd The ndarray to read the Reevenue per KPI data from.

Returns
The NDArrayInputDataBuilder with the added Revenue per KPI data.