Models¶
Core data structures used throughout synamine.
Event Log¶
EventLogSchema
dataclass
¶
EventLogSchema(
case_id: str = DEFAULT_CASE_ID,
activity: str = DEFAULT_ACTIVITY,
timestamp: str = DEFAULT_TIMESTAMP,
resource: str | None = None,
cost: str | None = None,
lifecycle: str | None = None,
extra_attributes: dict[str, str] = dict(),
)
Defines the column mapping for an event log DataFrame.
Event
dataclass
¶
Event(
activity: str,
timestamp: datetime,
resource: str | None = None,
attributes: dict[str, Any] = dict(),
)
A single event within a trace.
Trace
dataclass
¶
Trace(
case_id: str,
events: tuple[Event, ...],
attributes: dict[str, Any] = dict(),
)
An ordered sequence of events belonging to a single case.
EventLog
¶
EventLog(
data: DataFrame, schema: EventLogSchema | None = None
)
Primary event log representation, backed by a pandas DataFrame.
All algorithms accept EventLog. Internally wraps a DataFrame for performance; exposes trace-level iteration for convenience.
Directly-Follows Graph¶
DirectlyFollowsGraph
dataclass
¶
DirectlyFollowsGraph(
edges: dict[tuple[str, str], int] = dict(),
start_activities: dict[str, int] = dict(),
end_activities: dict[str, int] = dict(),
)
A graph of directly-follows relations between activities.
Each edge (A, B) with count N means activity B directly followed activity A in N traces.
Petri Net¶
Transition
dataclass
¶
PetriNet
dataclass
¶
PetriNet(
name: str = "",
places: set[Place] = set(),
transitions: set[Transition] = set(),
arcs: set[Arc] = set(),
initial_marking: Marking = Marking(),
final_marking: Marking = Marking(),
)
Process Tree¶
Operator
¶
Bases: Enum
ProcessTree
dataclass
¶
ProcessTree(
operator: Operator | None = None,
label: str | None = None,
parent: ProcessTree | None = None,
children: list[ProcessTree] = list(),
)
Variant Trie¶
VariantTrieNode
dataclass
¶
VariantTrieNode(
activity: str | None = None,
count: int = 0,
end_count: int = 0,
depth: int = 0,
children: dict[str, VariantTrieNode] = dict(),
parent: VariantTrieNode | None = None,
)
VariantTrie
dataclass
¶
VariantTrie(root: VariantTrieNode = VariantTrieNode())
A prefix tree of trace variants.
Built from an EventLog, each path root->leaf represents a unique process variant. Branch points reveal where executions diverge. Designed for dendrogram visualization.
Example
import synamine log = synamine.read_csv("orders.csv") trie = synamine.discover_variant_trie(log) print(trie) VariantTrie(variants=5, traces=1000, max_depth=8) synamine.view_variant_trie(trie) # Opens dendrogram
from_log
classmethod
¶
from_log(log: EventLog) -> VariantTrie
Build a variant trie from an event log.
| PARAMETER | DESCRIPTION |
|---|---|
log
|
The event log to build the trie from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VariantTrie
|
The constructed prefix tree. |
variants
¶
Yield all variants as (activity_sequence, count) tuples, sorted by count descending.
prune
¶
prune(min_count: int) -> VariantTrie
Return a new trie with nodes below min_count removed.
Prunes at the node level: any branch where the node count drops below min_count is cut off. This preserves the full structure of high-traffic paths and keeps the root count from the original trie so that percentages remain relative to the full log.