meridian.analysis.analyzer.DataTensors

Container for data variable arguments of Analyzer methods.

Inherits From: ExtensionType

media
Optional tensor with dimensions (n_geos, T, n_media_channels) for any time dimension T .
media_spend
Optional tensor with dimensions (n_media_channels,) or (n_geos, T, n_media_channels) for any time dimension T . If the object includes variables with modified time periods, then this tensor must be provided at the geo and time granularity.
reach
Optional tensor with dimensions (n_geos, T, n_rf_channels) for any time dimension T .
frequency
Optional tensor with dimensions (n_geos, T, n_rf_channels) for any time dimension T .
rf_impressions
Optional tensor with dimensions (n_geos, T, n_rf_channels) for any time dimension T .
rf_spend
Optional tensor with dimensions (n_rf_channels,) or (n_geos, T, n_rf_channels) for any time dimension T . If the object includes variables with modified time periods, then this tensor must be provided at the geo and time granularity.
organic_media
Optional tensor with dimensions (n_geos, T, n_organic_media_channels) for any time dimension T .
organic_reach
Optional tensor with dimensions (n_geos, T, n_organic_rf_channels) for any time dimension T .
organic_frequency
Optional tensor with dimensions (n_geos, T, n_organic_rf_channels) for any time dimension T .
non_media_treatments
Optional tensor with dimensions (n_geos, T, n_non_media_channels) for any time dimension T .
controls
Optional tensor with dimensions (n_geos, n_times, n_controls) .
revenue_per_kpi
Optional tensor with dimensions (n_geos, T) for any time dimension T .
time
Optional tensor of time coordinates in the "YYYY-mm-dd" string format for time dimension T .

Child Classes

class Spec

Methods

filter_fields

View source

Returns a new DataTensors object with only the specified fields.

get_modified_times

View source

Returns n_times of any tensor where n_times has been modified.

This method compares the time dimensions of the attributes in the DataTensors object with the corresponding tensors in the meridian object. If any of the time dimensions are different, then this method returns the modified number of time periods of the tensor in the DataTensors object. If all time dimensions are the same, returns None .

Args

meridian
A Meridian object to validate against and get the original data tensors from.

Returns
The n_times of any tensor where n_times is different from the times of the corresponding tensor in the meridian object. If all time dimensions are the same, returns None .

total_spend

View source

Returns the total spend tensor.

Returns
The media_spend tensor (if present) concatenated with the rf_spend tensor (if present), in this order. If both tensors are missing, returns None .

validate_and_fill_missing_data

View source

Fills missing data tensors with their original values from the model.

This method uses the collection of data tensors set in the DataTensor class and fills in the missing tensors with their original values from the Meridian object that is passed in. For example, if required_tensors_names = ["media", "reach", "frequency"] and only media is set in the DataTensors class, then this method will output a new DataTensors object with the media value in this object plus the values of the reach and frequency from the meridian object.

Args

required_tensors_names
A sequence of data tensors names to validate and fill in with the original values from the meridian object.
meridian
The Meridian object to validate against and get the original data tensors from.
allow_modified_times
A boolean flag indicating whether to allow modified time dimensions in the new data tensors. If False, an error will be raised if the time dimensions of any tensor is modified.

Returns
A DataTensors container with the original values from the Meridian object filled in for the missing data tensors.

__eq__

Return self==value.

__ne__

Return self!=value.

Design a Mobile Site
View Site in Mobile | Classic
Share by: