Simulate
Simulation
- class pysimmmulator.simulate.multisimmm
Provides capability to generate multiple runs on a single configuration
- property get_data
Provies the iterable generator for simulaton final dataframes and channel ground truth ROI values
- Parameters:
None
- Returns:
iterable of final sim dataframes and channel ROI values
- Return type:
data (iterable)
- run(config: dict, runs: int) None
- stash_outputs(final_df: DataFrame, channel_roi: dict)
Stores the final simulation dataframe as well as the ground truth channel ROI values for each run of the multiple simulations.
- class pysimmmulator.simulate.simmm(basic_params: basic_parameters = None, random_seed=None)
Takes input of basic params and provies either piece meal or single shot creation of MMM data using a config file,
- calculate_channel_roi() None
Calculates the ROI for all channels, based on pre-generated spend and conversions data
- Parameters:
None
- Returns:
None
- calculate_conversions() None
Calculates row wise values for conversions based on the noisy cvr and the adstocked media metric associated with each channel.
- Parameters:
None
- Returns:
None
- consolidate_dataframe() None
Filters and formats internal data into uniform output.
- Parameters:
None
- Returns:
None
- finalize_output(aggregation_level: str) None
Provide aggregation (daily, weekly) and column filtering for final output
- Parameters:
aggregation_level (str) – [daily, weekly] the granulatiry at which to return output data
- Returns:
None
- run_with_config(config: dict) set[DataFrame, dict]
- simulate_ad_spend(campaign_spend_mean: int, campaign_spend_std: int, max_min_proportion_on_each_channel: dict) None
Simulation of ad spend based on normal distribution parameters for campaign spend. Overall campaign spend is then divided amongst each channel based on passed min-max proportionality.
- Parameters:
campaign_spend_mean (int) – The average amount of money spent on a campaign.
campaign_spend_std (int) – The standard deviation of money spent on a campaign
max_min_proportion_on_each_channel (dict) – Specifies the minimum and maximum percentages of total spend allocated to each channel.
- Returns:
None
- simulate_baseline(base_p: int, trend_p: int, temp_var: int, temp_coef_mean: int, temp_coef_sd: int, error_std: int) None
Simulation of baseline sales and revenue for the subject business.
- Parameters:
basic_params (basic_parameters) – Number of years you want to generate data for.
base_p (int) – Amount of baseline sales we get in a day (sales not due to ads)
trend_p (int) – How much baseline sales is going to grow over the whole period of our data.
temp_var (int) – How big the height of the sine function is for temperature – i.e. how much temperature varies (used to inject seasonality into our data)
temp_coef_mean (int) – The average of how important seasonality is in our data (the larger this number, the more important seasonality is for sales)
temp_coef_sd (int) – The standard deviation of how important seasonality is in our data (the larger this number, the more variable the importance of seasonality is for sales)
error_std (int) – Amount of statistical noise added to baseline sales (the larger this number, the noisier baseline sales will be).
- Returns:
None
- simulate_cvr(noisy_cvr: dict) None
Generate Conversion Rate using the true conversion rates passed in the basic params in combination with noise parameters passed in this function.
- Parameters:
noisy_cpm_cpc (dict) – Specifies the bias and scale of noise added to the true value CVR for each channel.
- Returns:
None
- simulate_decay_returns(true_lambda_decay: dict, alpha_saturation: dict, gamma_saturation: dict) None
Generates the decay values associated with ad stocking.
- Parameters:
true_lambda_decay (dict) – Numbers between 0 and 1 specifying the lambda parameters for a geometric distribution for adstocking media variables.
alpha_saturation (dict) – Specifying alpha parameter of geometric distribution for applying diminishing returns to media variables
gamma_saturation (dict) – Between 0 and 1 specifying gamma parameter of geometric distribution for applying diminishing returns to media variables
- Returns:
None
- simulate_media(true_cpm: dict, true_cpc: dict, noisy_cpm_cpc: dict) None
Simulation of relevant media metrics for each channel. True values are passed and noise is applied in accordance with a normal distribution described within the noisy dict. Media metrics are checked for 0 values stemming from the random noise applied and will be flagged with logger when found. It is generally understood that negativ evalues should not arrise for media metrics.
- Parameters:
true_cpm (dict) – Specifies the true Cost per Impression (CPM) of each channel (noise will be added to this to simulate number of impressions)
true_cpc (dict) – Specifies the true Cost per Click (CPC) of each channel (noise will be added to this to simulate number of clicks)
noisy_cpm_cpc (dict) – Specifies the bias and scale of noise added to the true value CPM or CPC for each channel.
- Returns:
None
Visualization
- class pysimmmulator.visualize.visualize
- plot_clicks(agg: str = None)
Plot simulated clicks data based on a passed date-wise aggregation
- Parameters:
agg (str) – pick from [{’, ‘.join(self._valid_agg_levels)}] to aggregate simulated data by
- plot_impressions(agg: str = None)
Plot simulated impressions data based on a passed date-wise aggregation
- Parameters:
agg (str) – pick from [{’, ‘.join(self._valid_agg_levels)}] to aggregate simulated data by
- plot_revenue(agg: str = None)
Plot simulated revenue data based on a passed date-wise aggregation
- Parameters:
agg (str) – pick from [{’, ‘.join(self._valid_agg_levels)}] to aggregate simulated data by
- plot_spend(agg: str = None)
Plot simulated spend data based on a passed date-wise aggregation
- Parameters:
agg (str) – pick from [{’, ‘.join(self._valid_agg_levels)}] to aggregate simulated data by