Sequence From Table#
Source: examples/sequence_from_table.py
Introduction#
Convert a short event log into a transition model that describes the team’s design-process flow.
Technical Implementation#
Construct event rows with timestamps, session IDs, and event labels.
Fit a first-order Markov chain with additive smoothing.
Print state order and transition probabilities.
1from __future__ import annotations
2
3import design_research_analysis as dran
4
5
6def main() -> None:
7 """Fit and print a transition matrix."""
8 rows = [
9 {
10 "timestamp": "2026-01-01T10:00:00Z",
11 "session_id": "s1",
12 "event_type": "propose",
13 },
14 {
15 "timestamp": "2026-01-01T10:01:00Z",
16 "session_id": "s1",
17 "event_type": "evaluate",
18 },
19 {
20 "timestamp": "2026-01-01T10:02:00Z",
21 "session_id": "s1",
22 "event_type": "refine",
23 },
24 {
25 "timestamp": "2026-01-01T10:03:00Z",
26 "session_id": "s1",
27 "event_type": "evaluate",
28 },
29 ]
30 result = dran.fit_markov_chain_from_table(rows, order=1, smoothing=1.0)
31 print(result.states)
32 print(result.transition_matrix)
33
34
35if __name__ == "__main__":
36 main()
Expected Results#
Run Command
PYTHONPATH=src python examples/sequence_from_table.py
Prints a tuple state list and a dense transition matrix suitable for downstream visualization or comparison across sessions.
References#
docs/workflows.rst