![]() |
Builds InputData
from n-dimensional arrays.
Inherits From: InputDataBuilder
meridian.data.nd_array_input_data_builder.NDArrayInputDataBuilder(
kpi_type: str
)
Attributes | |
---|---|
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
build() -> meridian.data.input_data.InputData
Builds an InputData
.
Constructs an InputData
from constituent DataArray
s 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
with_controls(
nd: np.ndarray, control_names: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_kpi(
nd: np.ndarray
) -> 'NDArrayInputDataBuilder'
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
with_media(
m_nd: np.ndarray, ms_nd: np.ndarray, media_channels: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_non_media_treatments(
nd: np.ndarray, non_media_channel_names: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_organic_media(
nd: np.ndarray, organic_media_channels: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_organic_reach(
or_nd: np.ndarray, of_nd: np.ndarray, organic_rf_channels: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_population(
nd: np.ndarray
) -> 'NDArrayInputDataBuilder'
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
with_reach(
r_nd: np.ndarray,
f_nd: np.ndarray,
rfs_nd: np.ndarray,
rf_channels: list[str]
) -> 'NDArrayInputDataBuilder'
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
with_revenue_per_kpi(
nd: np.ndarray
) -> 'NDArrayInputDataBuilder'
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.
|