seismometer.configuration.model.Event

pydantic model seismometer.configuration.model.Event

The definition of an event.

This structure defines an event and which predictions are relevant to it. If a window is specified:

  • the offset_hr defines the upper bound of the window relative to the event time, has default value of 0 (event time),

  • the window_hr defines the size of the window looking backwards from the offset_hr.

If an event is present but the prediction is not in the window, the predictions are ignored for the event type. If multiple events are present then the closest one is used.

The impute_val is used as the value for the event if no event is present.

Usage is used for context when selecting events, such as analyzing performance of the model with respect to a target or when comparing an expected intervention to a monitored outcome.

Show Entity Relationship Diagram
digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "seismometer.configuration.model.Event"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>Event</b></td></tr><tr><td>source</td><td port="source">list[str]</td></tr><tr><td>display_name</td><td port="display_name">str</td></tr><tr><td>window_hr</td><td port="window_hr">Optional[float]</td></tr><tr><td>offset_hr</td><td port="offset_hr">float</td></tr><tr><td>impute_val</td><td port="impute_val">Optional[Any]</td></tr><tr><td>usage</td><td port="usage">Optional[str]</td></tr><tr><td>aggregation_method</td><td port="aggregation_method">Optional[Literal['min', 'max', 'first', 'last']]</td></tr><tr><td>merge_strategy</td><td port="merge_strategy">Optional[Literal['first', 'last', 'nearest', 'forward', 'count']]</td></tr></table>>,
      tooltip="seismometer.configuration.model.Event&#xA;&#xA;The definition of an event.&#xA;&#xA;This structure defines an event and which predictions \
are relevant to it.&#xA;If a window is specified:&#xA;&#xA;- the offset_hr defines the upper bound of the window relative to the \
event time,&#xA;  has default value of 0 (event time),&#xA;- the window_hr defines the size of the window looking backwards from \
the offset_hr.&#xA;&#xA;If an event is present but the prediction is not in the window, the predictions are ignored for the event \
type.&#xA;If multiple events are present then the closest one is used.&#xA;&#xA;The impute_val is used as the value for the event \
if no event is present.&#xA;&#xA;Usage is used for context when selecting events, such as analyzing performance of the model with \
respect to a&#xA;target or when comparing an expected intervention to a monitored outcome.&#xA;"];
}

Show JSON schema
{
   "title": "Event",
   "description": "The definition of an event.\n\nThis structure defines an event and which predictions are relevant to it.\nIf a window is specified:\n\n- the offset_hr defines the upper bound of the window relative to the event time,\n  has default value of 0 (event time),\n- the window_hr defines the size of the window looking backwards from the offset_hr.\n\nIf an event is present but the prediction is not in the window, the predictions are ignored for the event type.\nIf multiple events are present then the closest one is used.\n\nThe impute_val is used as the value for the event if no event is present.\n\nUsage is used for context when selecting events, such as analyzing performance of the model with respect to a\ntarget or when comparing an expected intervention to a monitored outcome.",
   "type": "object",
   "properties": {
      "source": {
         "items": {
            "type": "string"
         },
         "title": "Source",
         "type": "array"
      },
      "display_name": {
         "default": "",
         "title": "Display Name",
         "type": "string"
      },
      "window_hr": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Window Hr"
      },
      "offset_hr": {
         "default": 0,
         "title": "Offset Hr",
         "type": "number"
      },
      "impute_val": {
         "anyOf": [
            {},
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Impute Val"
      },
      "usage": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Usage"
      },
      "aggregation_method": {
         "anyOf": [
            {
               "enum": [
                  "min",
                  "max",
                  "first",
                  "last"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "max",
         "title": "Aggregation Method"
      },
      "merge_strategy": {
         "anyOf": [
            {
               "enum": [
                  "first",
                  "last",
                  "nearest",
                  "forward",
                  "count"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "forward",
         "title": "Merge Strategy"
      }
   },
   "required": [
      "source"
   ]
}

Fields:
Validators:
field aggregation_method: Literal['min', 'max', 'first', 'last'] | None = 'max'

The strategy for aggregating (or selecting) scores for an event. Supports min, max, first, and last; defaulting to max.

field display_name: str = ''

The display name for the event.

If not specified, defaults to the source name if singular, otherwise must be specified. Display names must be unique across the dataset and are what is referenced in usage configuration.

Validated by:
field impute_val: Any | None = None

The value to use if no event is present.

field merge_strategy: Literal['first', 'last', 'nearest', 'forward', 'count'] | None = 'forward'

The strategy for merging events with predictions. Supports first, last, nearest, forward, and count; defaulting to forward.

- first: The first event within the window is selected. If no window, the first event is selected.
- last: The last event within the window is selected. If no window, the last event is selected.
- nearest: The event closest to the prediction time within the window is selected. If no window, the nearest event is selected.
- forward: The first event at or after the prediction time within the window is selected. If no window, the first event at or after the prediction time is selected.
- count: Creates a count column for each event value for specified event label. This column tracks the occurrences of each event value for each prediction. Counts respects the window.
field offset_hr: float = 0

The number of hours to offset the valid window before the reference time.

field source: list[str] [Required]

The source(s) for an event.

Supports a single event type or a list of event types. If a list is provided, the display_name must be specified.

Validated by:
field usage: str | None = None

The type of event being defined; can be target, intervention, or outcome.

field window_hr: float | None = None

The size of the valid window in hours.

validator coerce_source_list  »  source

Coerce single values for source into a list so all downstream processing can assume a list.

Return type:

list[str]

validator default_display_name  »  display_name

Ensures that display_name exists.

If display_name is not explicitly set, it will be set to the source name if singular valued. When multiple sources, raise an error if no display_name is provided.

Parameters:
  • display_name (str)

  • values (dict)

Return type:

str