The :class:EventLog dataclass — the OCEL 2.0 relational tables.
Classes
| Name | Description |
|---|
EventLog | Canonical ts-shape event log in OCEL 2.0 shape. |
EventLog(
events: pd.DataFrame = schema.empty_events(),
objects: pd.DataFrame = schema.empty_objects(),
relations: pd.DataFrame = schema.empty_relations(),
o2o: pd.DataFrame = schema.empty_o2o(),
object_changes: pd.DataFrame = schema.empty_object_changes(),
) -> None
Canonical ts-shape event log in OCEL 2.0 shape.
Five relational tables, mirroring the OCEL 2.0 standard:
events — one row per detected event (+ event attributes),
objects — the objects events refer to (ocel:oid / ocel:type),
relations — event-to-object (E2O) relations with qualifiers,
o2o — object-to-object relations with qualifiers,
object_changes — time-varying object attribute values.
objects / relations are empty when the source detector has no
natural object association (e.g. a global cross-signal correlation
statistic); o2o / object_changes are empty unless supplied. Use
:attr:has_objects to check before calling :func:to_event_log_xes.
Example
Built by :func:~ts_shape.to_event_log from a detector's output:
>>> import ts_shape
>>> df = ts_shape.make_timeseries(["temp"], n_outliers=3)
>>> out = ts_shape.OutlierDetectionEvents(df, "value_double").detect_outliers_zscore()
>>> log = ts_shape.to_event_log(
... out, detector="OutlierDetectionEvents.detect_outliers_zscore")
>>> len(log.events), log.has_objects
(4, True)
>>> log.events[["ocel:activity", "ocel:timestamp"]].head(2)
ocel:activity ocel:timestamp
0 quality.outlier.zscore 2025-01-01 01:34:30+00:00
1 quality.outlier.zscore 2025-01-01 03:21:00+00:00
Functions
| Name | Description |
|---|
filter_by_pack | Return a sub-log containing only the events emitted by one pack. |
filter_by_object | Return a sub-log containing only the events related to one object. |
filter_by_object_type | Return a sub-log containing only the objects of some types. |
filter_by_time | Return a sub-log of the half-open time window [start, end). |
where_used | Everything oid went into; see :func:~ts_shape.eventlog.where_used. |
where_from | Everything oid came from; see :func:~ts_shape.eventlog.where_from. |
lineage | Both directions with a signed depth; see :func:~ts_shape.eventlog.lineage. |
Whether the log contains at least one object in objects.
filter_by_pack(pack: str) -> EventLog
Return a sub-log containing only the events emitted by one pack.
Objects, relations, object-to-object links, and object changes are
restricted to those referenced by the kept events.
Parameters
| Name | Type | Description | Default |
|---|
pack | str | Pack name to match against the ts_shape:pack column. | required |
Returns
| Type | Description |
|---|
EventLog | A new EventLog restricted to the matching events. |
filter_by_object(oid: str, type_: str | None = None) -> EventLog
Return a sub-log containing only the events related to one object.
Events are selected through the event-to-object relations table;
the other tables are restricted to the objects those events use.
Parameters
| Name | Type | Description | Default |
|---|
oid | str | Object identifier (ocel:oid) to match. | required |
type_ | str | None | Optional object type (ocel:type) to match as well. | None |
Returns
| Type | Description |
|---|
EventLog | A new EventLog restricted to the events related to the object. |
filter_by_object_type(
types: str | Iterable[str],
*,
keep_events: Literal["linked", "all"] = "linked"
) -> EventLog
Return a sub-log containing only the objects of some types.
objects keeps every object of types (also one no event links
to); relations, o2o (both ends) and object_changes are
restricted to those objects, so no table references a dropped one.
Parameters
| Name | Type | Description | Default |
|---|
types | str | Iterable[str] | Object type(s) (ocel:type) to keep. | required |
keep_events | Literal['linked', 'all'] | "linked" keeps the events related to at least one kept object; "all" keeps every event (their relations to other objects are dropped). | 'linked' |
Returns
| Type | Description |
|---|
EventLog | A new EventLog restricted to the objects of types. |
Raises
| Type | Description |
|---|
ValueError | For an unknown keep_events. |
filter_by_time(start: object = None, end: object = None) -> EventLog
Return a sub-log of the half-open time window start, end).
events: those whose ocel:timestamp is in the window.
objects: those present in the window (a lifecycle
active -> released span of object_changes overlaps it),
those without lifecycle rows (presence unknown), and every object a
kept event relates to.
relations of the kept events; o2o with both ends kept.
object_changes of the kept objects inside the window, plus each
field's last value before start (the state at the window start).
Parameters
| Name | Type | Description | Default |
|---|
start | [object | Window start (inclusive); None: unbounded. Naive times are UTC. | None |
end | object | Window end (exclusive); None: unbounded. | None |
Returns
| Type | Description |
|---|
EventLog | A new EventLog restricted to the window. |
Raises
| Type | Description |
|---|
ValueError | When start is not before end. |
where_used(
oid: str,
*,
depth: int | None = None,
start: object = None,
end: object = None,
qualifiers: str | Iterable[str] | None = None
) -> pd.DataFrame
Everything oid went into; see :func:~ts_shape.eventlog.where_used.
Parameters
| Name | Type | Description | Default |
|---|
oid | str | The object to start from. | required |
depth | int | None | Maximum number of steps; None: no limit. | None |
start | object | Window start (inclusive). | None |
end | object | Window end (exclusive). | None |
qualifiers | str | Iterable[str] | None | The o2o qualifiers to follow (default: all but co_occurs). | None |
Returns
| Type | Description |
|---|
DataFrame | oid, object_type, qualifier, depth, via (+ extra |
DataFrame | o2o columns). |
where_from(
oid: str,
*,
depth: int | None = None,
start: object = None,
end: object = None,
qualifiers: str | Iterable[str] | None = None
) -> pd.DataFrame
Everything oid came from; see :func:~ts_shape.eventlog.where_from.
Parameters
| Name | Type | Description | Default |
|---|
oid | str | The object to start from. | required |
depth | int | None | Maximum number of steps; None: no limit. | None |
start | object | Window start (inclusive). | None |
end | object | Window end (exclusive). | None |
qualifiers | str | Iterable[str] | None | The o2o qualifiers to follow (default: all but co_occurs). | None |
Returns
| Type | Description |
|---|
DataFrame | oid, object_type, qualifier, depth, via (+ extra |
DataFrame | o2o columns). |
lineage(
oid: str,
*,
depth: int | None = None,
start: object = None,
end: object = None,
qualifiers: str | Iterable[str] | None = None
) -> pd.DataFrame
Both directions with a signed depth; see :func:~ts_shape.eventlog.lineage.
Parameters
| Name | Type | Description | Default |
|---|
oid | str | The object to start from. | required |
depth | int | None | Maximum number of steps per direction; None: no limit. | None |
start | object | Window start (inclusive). | None |
end | object | Window end (exclusive). | None |
qualifiers | str | Iterable[str] | None | The o2o qualifiers to follow (default: all but co_occurs). | None |
Returns
| Name | Type | Description |
|---|
The | DataFrame | meth:where_from rows at negative depth, oid at 0, |
the | DataFrame | meth:where_used rows at positive depth. |