View source on GitHub
|
Model context for Meridian.
meridian.model.context.ModelContext(
input_data: meridian.data.input_data.InputData,
model_spec: meridian.model.spec.ModelSpec
)
This class contains all model parameters that do not change between the runs of Meridian.
Methods
create_inference_data_coords
create_inference_data_coords(
n_chains: int, n_draws: int
) -> Mapping[str, np.ndarray | Sequence[str]]
Creates data coordinates for inference data.
create_inference_data_dims
create_inference_data_dims() -> Mapping[str, Sequence[str]]
Creates data dimensions for inference data.
expand_selected_time_dims
expand_selected_time_dims(
start_date: meridian.data.time_coordinates.Date = None,
end_date: meridian.data.time_coordinates.Date = None
) -> (list[str] | None)
Validates and returns time dimension values based on the selected times.
If both start_date and end_date are None, returns None. If specified,
both start_date and end_date are inclusive, and must be present in the
time coordinates of the input data.
| Args | |
|---|---|
start_date
|
Start date of the selected time period. If None, implies the earliest time dimension value in the input data. |
end_date
|
End date of the selected time period. If None, implies the latest time dimension value in the input data. |
| Returns | |
|---|---|
A list of time dimension values (as Meridian-formatted strings) in the
input data within the selected time period, or do nothing and pass through
None if both arguments are Nones, or if start_date and end_date
correspond to the entire time range in the input data.
|
| Raises | |
|---|---|
ValueError if start_date or end_date is not in the input data time
dimensions.
|
populate_cached_properties
populate_cached_properties()
Eagerly activates all cached properties.
This is useful for creating a tf.function computation graph with this
Meridian object as part of a captured closure. Within the computation graph,
internal state mutations are problematic, and so this method freezes the
object's states before the computation graph is created.
View source on GitHub