utils#

Utility functions for the Marketing Mix Modeling module.

Functions

add_noise_to_channel_allocation(df, channels)

Return df with additive Gaussian noise applied to channels columns.

adjusted_value_at_risk_score([...])

Calculate adjusted Value at Risk (AVaR) score.

apply_sklearn_transformer_across_dim(data, ...)

Apply a scikit-learn transformer across a dimension of an xarray DataArray.

average_response(samples, budgets)

Compute the average response of the posterior predictive distribution.

build_contributions(idata, var[, agg, ...])

Build a wide contributions DataFrame from idata.posterior variables.

conditional_value_at_risk([confidence_level])

Calculate the Conditional Value at Risk (CVaR) at a specified confidence level.

create_index(dims, take)

Create an index to take the first dimension of a tensor based on the provided dimensions.

create_new_spend_data(spend, ...[, ...])

Create new spend data for the channel forward pass.

create_zero_dataset(model, start_date, end_date)

Create a DataFrame for future prediction, with zeros (or supplied constants).

diversification_ratio(samples, budgets)

Calculate the Diversification Ratio of a portfolio to evaluate risk distribution.

mean_tightness_score([alpha, confidence_level])

Calculate the Mean Tightness Score (MTS).

portfolio_entropy(samples, budgets)

Calculate the entropy of a portfolio's asset weights to assess diversification.

raroc([risk_free_rate])

Calculate the Risk-Adjusted Return on Capital (RAROC).

sharpe_ratio([risk_free_rate])

Calculate the Sharpe Ratio.

tail_distance([confidence_level])

Calculate the absolute distance between the mean and the quantiles.

transform_1d_array(transform, y)

Transform a 1D array using a scikit-learn transformer.

value_at_risk([confidence_level])

Calculate the Value at Risk (VaR) at a specified confidence level.