View source on GitHub
|
Container for data variable arguments of Analyzer methods.
Inherits From: ExtensionType
meridian.analysis.analyzer.DataTensors(
media: Optional[meridian.backend.Tensor] = None,
media_spend: Optional[meridian.backend.Tensor] = None,
reach: Optional[meridian.backend.Tensor] = None,
frequency: Optional[meridian.backend.Tensor] = None,
rf_impressions: Optional[meridian.backend.Tensor] = None,
rf_spend: Optional[meridian.backend.Tensor] = None,
organic_media: Optional[meridian.backend.Tensor] = None,
organic_reach: Optional[meridian.backend.Tensor] = None,
organic_frequency: Optional[meridian.backend.Tensor] = None,
non_media_treatments: Optional[meridian.backend.Tensor] = None,
controls: Optional[meridian.backend.Tensor] = None,
revenue_per_kpi: Optional[meridian.backend.Tensor] = None,
time: Optional[meridian.backend.Tensor] = None
)
Child Classes
Methods
filter_fields
filter_fields(
fields: Sequence[str]
) -> Self
Returns a new DataTensors object with only the specified fields.
get_modified_times
get_modified_times(
meridian: (meridian.model.model.Meridian | None) = None,
model_context: (meridian.model.context.ModelContext | None) = None
) -> (int | None)
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 model_context
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
|
Deprecated. A Meridian object to validate against and get the
original data tensors from. This argument is deprecated and will be
removed in a future version. Use model_context instead.
|
model_context
|
A ModelContext 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 model_context object. If all time
dimensions are the same, returns None.
|
total_spend
total_spend() -> (meridian.backend.Tensor | None)
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
validate_and_fill_missing_data(
required_tensors_names: Sequence[str],
meridian: (meridian.model.model.Meridian | None) = None,
model_context: (meridian.model.context.ModelContext | None) = None,
allow_modified_times: bool = True
) -> Self
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
ModelContext 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 model_context object.
| Args | |
|---|---|
required_tensors_names
|
A sequence of data tensors names to validate and
fill in with the original values from the model_context object.
|
meridian
|
Deprecated. A Meridian object to validate against and get the
original data tensors from. This argument is deprecated and will be
removed in a future version. Use model_context instead.
|
model_context
|
A ModelContext 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__
__eq__(
other: Any
) -> bool
Provides safe equality comparison for mixed tensor/non-tensor fields.
__ne__
__ne__(
other
)
Return self!=value.
View source on GitHub