Simulated data is provided as an example for each data type and format in the following sections.
CSV
To load the
simulated CSV data
using CsvDataLoader
:
Map the column names to the variable types. The required variable types are
time
,geo
,controls
,population
,kpi
, andrevenue_per_kpi
. For media channels that don't have reach and frequency data, you must assign their media exposure and media spend to the categories ofmedia
andmedia_spend
, respectively. Conversely, for media channels that do possess reach and frequency data, you must map their reach, frequency, and media spend to the categories ofreach
,frequency
, andrf_spend
correspondingly. For the definition of each variable, see Collect and organize your data.coord_to_columns = load.CoordToColumns( time='time', geo='geo', controls=['GQV', 'Discount', 'Competitor_Sales'], population='population', kpi='conversions', revenue_per_kpi='revenue_per_conversion', media=[ 'Channel0_impression', 'Channel1_impression', 'Channel2_impression', 'Channel3_impression', ], media_spend=[ 'Channel0_spend', 'Channel1_spend', 'Channel2_spend', 'Channel3_spend', ], reach =['Channel4_reach', 'Channel5_reach'], frequency=['Channel4_frequency', 'Channel5_frequency'], rf_spend=['Channel4_spend', 'Channel5_spend'], )
Map the media exposure, reach, frequency, and the media spends to the designated channel names that you want to display in the two-page output. In the following example,
Channel0_impression
andChannel0_spend
are connected to the same channel,Channel0
. Additionally,Channel4_reach
,Channel4_frequency
, andChannel4_spend
are connected to the same channel,Channel4
.correct_media_to_channel = { 'Channel0_impression': 'Channel0', 'Channel1_impression': 'Channel1', 'Channel2_impression': 'Channel2', 'Channel3_impression': 'Channel3', } correct_media_spend_to_channel = { 'Channel0_spend': 'Channel0', 'Channel1_spend': 'Channel1', 'Channel2_spend': 'Channel2', 'Channel3_spend': 'Channel3', } correct_reach_to_channel = { 'Channel4_reach': 'Channel4', 'Channel5_reach': 'Channel5', } correct_frequency_to_channel = { 'Channel4_frequency': 'Channel4', 'Channel5_frequency': 'Channel5', } correct_rf_spend_to_channel = { 'Channel4_spend': 'Channel4', 'Channel5_spend': 'Channel5', }
Load the data using
CsvDataLoader
:loader = load.CsvDataLoader( csv_path=f'/{PATH}/{FILENAME}.csv', kpi_type='non_revenue', coord_to_columns=coord_to_columns, media_to_channel=correct_media_to_channel, media_spend_to_channel=correct_media_spend_to_channel, reach_to_channel=correct_reach_to_channel, frequency_to_channel=correct_frequency_to_channel, rf_spend_to_channel=correct_rf_spend_to_channel, ) data = loader.load()
Where:
kpi_type
is either'revenue'
or'non_revenue'
.PATH
is the path to the data file location.FILENAME
is the name of your data file.
Xarray Dataset
To load the
simulated Xarray Dataset
using XrDatasetDataLoader
:
Load the data using
pickle
:import pickle with open(f'/{PATH}/{FILENAME}.pkl', 'r') as fh: XrDataset=pickle.load(fh)
Where:
PATH
is the path to the data file location.FILENAME
is the name of your data file.
Pass the dataset to
XrDatasetDataLoader
. Use thename_mapping
argument to map the coordinates and arrays. Provide mapping if the names in the input dataset are different from the required names. The required coordinate names aregeo
,time
,control_variable
,media_channel
, andrf_channel
, whererf_channel
designates the channels having reach and frequency data. The required data variables names arekpi
,revenue_per_kpi
,controls
,population
,media
,media_spend
,reach
,frequency
, andrf_spend
.loader = load.XrDatasetDataLoader( XrDataset, kpi_type='non_revenue', name_mapping={ 'channel': 'media_channel', 'control': 'control_variable', 'conversions': 'kpi', 'revenue_per_conversion': 'revenue_per_kpi', 'control_value': 'controls', 'spend': 'media_spend', 'reach': 'reach', 'frequency': 'frequency', 'rf_spend': 'rf_spend', }, ) data = loader.load()
Where:
kpi_type
is either'revenue'
or'non_revenue'
.
Other Data Format
To load the simulated other data
format
(such as excel
) using DataFrameDataLoader
:
Map the column names to the variable types. The required variable types are
time
,geo
,controls
,population
,kpi
, andrevenue_per_kpi
. For media channels that don't have reach and frequency data, you must assign their media exposure and media spend to the categories ofmedia
andmedia_spend
, respectively. Conversely, for media channels that do possess reach and frequency data, you must map their reach, frequency, and media spend to the categories ofreach
,frequency
, andrf_spend
correspondingly. For the definition of each variable, see Collect and organize your data.coord_to_columns = load.CoordToColumns( time='time', geo='geo', controls=['GQV', 'Discount', 'Competitor_Sales'], population='population', kpi='conversions', revenue_per_kpi='revenue_per_conversion', media=[ 'Channel0_impression', 'Channel1_impression', 'Channel2_impression', 'Channel3_impression', ], media_spend=[ 'Channel0_spend', 'Channel1_spend', 'Channel2_spend', 'Channel3_spend', ], reach =['Channel4_reach', 'Channel5_reach'], frequency=['Channel4_frequency', 'Channel5_frequency'], rf_spend=['Channel4_spend', 'Channel5_spend'], )
Map the media exposure, reach, frequency and the media spends to the designated channel names that you want to display in the two-page output. In the following example,
Channel0_impression
andChannel0_spend
are connected to the same channel,Channel0
. Additionally,Channel4_reach
,Channel4_frequency
, andChannel4_spend
are connected to the same channel,Channel4
.correct_media_to_channel = { 'Channel0_impression': 'Channel0', 'Channel1_impression': 'Channel1', 'Channel2_impression': 'Channel2', 'Channel3_impression': 'Channel3', } correct_media_spend_to_channel = { 'Channel0_spend': 'Channel0', 'Channel1_spend': 'Channel1', 'Channel2_spend': 'Channel2', 'Channel3_spend': 'Channel3', } correct_reach_to_channel = { 'Channel4_reach': 'Channel4', 'Channel5_reach': 'Channel5', } correct_frequency_to_channel = { 'Channel4_frequency': 'Channel4', 'Channel5_frequency': 'Channel5', } correct_rf_spend_to_channel = { 'Channel4_spend': 'Channel4', 'Channel5_spend': 'Channel5', }
Read the data (such as
excel
) intoDataFrameDataLoader
, and then load the data:df = pd.read_excel(f'/{PATH}/{FILENAME}.xlsx') loader = load.DataFrameDataLoader( df=df, kpi_type='non_revenue', coord_to_columns=coord_to_columns, media_to_channel=correct_media_to_channel, media_spend_to_channel=correct_media_spend_to_channel, reach_to_channel=correct_reach_to_channel, frequency_to_channel=correct_frequency_to_channel, rf_spend_to_channel=correct_rf_spend_to_channel, ) data = loader.load()
Where:
kpi_type
is either'revenue'
or'non_revenue'
.PATH
is the path to the data file location.FILENAME
is the name of your data file.
Next, you can create your model.