Idea Space Metrics#
Source: examples/idea_space_metrics.py
Introduction#
Build a compact idea-space analysis from deterministic vectors, then render the timeline, trajectory, and convergence views that support interpretation.
Technical Implementation#
Construct a single-session unified table plus a deterministic numeric space.
Compute projection-space coverage, trajectory summaries, and divergence markers.
Render three plots and save them to a stable output directory.
1from __future__ import annotations
2
3import argparse
4from pathlib import Path
5
6import matplotlib.pyplot as plt
7import numpy as np
8
9import design_research_analysis as dran
10
11
12def parse_args() -> argparse.Namespace:
13 """Parse optional example arguments."""
14 parser = argparse.ArgumentParser(description=__doc__)
15 parser.add_argument(
16 "--output-dir",
17 default="artifacts/examples/idea_space_metrics",
18 help="Directory where PNG files should be written.",
19 )
20 return parser.parse_args()
21
22
23def main() -> None:
24 """Run a compact idea-space metrics and visualization workflow."""
25 args = parse_args()
26 output_dir = Path(args.output_dir)
27 output_dir.mkdir(parents=True, exist_ok=True)
28
29 rows = [
30 {
31 "timestamp": "2026-01-01T10:00:00Z",
32 "session_id": "session-a",
33 "actor_id": "alice",
34 "event_type": "propose",
35 "text": "initial sketch",
36 },
37 {
38 "timestamp": "2026-01-01T10:01:00Z",
39 "session_id": "session-a",
40 "actor_id": "bob",
41 "event_type": "evaluate",
42 "text": "compare alternatives",
43 },
44 {
45 "timestamp": "2026-01-01T10:02:00Z",
46 "session_id": "session-a",
47 "actor_id": "alice",
48 "event_type": "refine",
49 "text": "merge promising features",
50 },
51 {
52 "timestamp": "2026-01-01T10:03:00Z",
53 "session_id": "session-a",
54 "actor_id": "bob",
55 "event_type": "prototype",
56 "text": "externalize the concept",
57 },
58 {
59 "timestamp": "2026-01-01T10:04:00Z",
60 "session_id": "session-a",
61 "actor_id": "alice",
62 "event_type": "evaluate",
63 "text": "assess feasibility",
64 },
65 ]
66 vectors = np.asarray(
67 [
68 [0.0, 0.0],
69 [0.6, 0.3],
70 [1.3, 1.2],
71 [1.8, 1.9],
72 [1.2, 1.4],
73 ],
74 dtype=float,
75 )
76 timestamps = [row["timestamp"] for row in rows]
77 groups = [row["session_id"] for row in rows]
78
79 coverage = dran.compute_design_space_coverage(vectors)
80 trajectory = dran.compute_idea_space_trajectory(vectors, timestamps=timestamps, groups=groups)
81 dynamics = dran.compute_divergence_convergence(trajectory, window=2)
82
83 timeline_fig, _ = dran.plot_design_process_timeline(rows, session_id="session-a")
84 timeline_fig.savefig(output_dir / "design_process_timeline.png", dpi=160, bbox_inches="tight")
85 plt.close(timeline_fig)
86
87 trajectory_fig, _ = dran.plot_idea_trajectory(vectors, timestamps=timestamps, groups=groups)
88 trajectory_fig.savefig(output_dir / "idea_trajectory.png", dpi=160, bbox_inches="tight")
89 plt.close(trajectory_fig)
90
91 session_series = trajectory["groups"]["session-a"]["centroid_distances"]
92 convergence_fig, _ = dran.plot_convergence_curve(session_series, ylabel="Centroid Distance")
93 convergence_fig.savefig(output_dir / "convergence_curve.png", dpi=160, bbox_inches="tight")
94 plt.close(convergence_fig)
95
96 print("Hull supported:", coverage["convex_hull"]["supported"])
97 print("Dominant direction:", dynamics["groups"]["session-a"]["dominant_direction"])
98 print("Output directory:", output_dir)
99
100
101if __name__ == "__main__":
102 main()
Expected Results#
Run Command
PYTHONPATH=src python examples/idea_space_metrics.py
Prints the convex-hull support flag, the dominant trajectory direction, and the directory containing the generated PNG figures.
References#
docs/workflows_embedding_maps.rst
docs/workflows_sequence.rst