Timelines and trajectories
The memory forgets, but its record does not. Because every statistic is a sum of the items written to a node, the History can recompute a node’s mass, centre and concentration at any past time, exactly with the hard write and from each item’s share in its own node with the soft write. The outputs on this page come from the Portal stream read with Memory() (Example data).
First, three nodes to follow, found by query as in Thematic retrieval:
from vmfstream.encode import SentenceEncoder
events = {"COVID-19": ("2020-03-11", "Coronavirus COVID-19 pandemic"), "Ukraine": ("2022-02-24", "Russian invasion of Ukraine"), "Gaza": ("2023-10-07", "Hamas attack on Israel and war in Gaza")}queries = memory.project(SentenceEncoder().encode([q for _, q in events.values()]))nodes = {name: history.query(q, time=hours_at(day), k=1)[0][0] for (name, (day, _)), q in zip(events.items(), queries)}nodes{'COVID-19': 3629, 'Ukraine': 5073, 'Gaza': 6207}Mass over time
Section titled “Mass over time”History.masses recomputes the forgotten mass of nodes on a regular grid. A node’s mass is roughly how many items it received in the last couple of half-lives, so its peak marks the busiest days of the story:
grid, mass = history.masses(nodes=list(nodes.values()), every=24)for (name, node), row in zip(nodes.items(), mass): peak = row.argmax() print(f"{name:<8} node {node}: peak mass {row[peak]:5.1f} on {day_of(grid[peak])}")COVID-19 node 3629: peak mass 21.7 on 2020-03-13 Ukraine node 5073: peak mass 61.7 on 2022-02-28 Gaza node 6207: peak mass 40.9 on 2023-10-16
vmfstream.viz.timeline draws the mass of the largest nodes as bands, here labelled by each node’s most central item:
from vmfstream.viz import timeline
labels = {n: texts[history.exemplars(n, central=1, diverse=0)[0]][:48] + "…" for n in history.largest(8)}fig = timeline(history, top=8, labels=labels)fig.savefig("timeline.svg", bbox_inches="tight")The largest nodes are recurring kinds of report, such as daily COVID-19 counts, rather than single events; their bands stay up for months. A single event, like an attack, makes a narrow spike that thins within days.
Trajectory of a centre
Section titled “Trajectory of a centre”The centre of a node moves as it receives items: old items weigh less in the sum, new ones turn it towards themselves. History.trajectory returns the centre on a grid of times, computed as the memory computes it:
grid, centre, mass = history.trajectory(nodes["Ukraine"], every=24)drift = centre @ centre[0]for day in (0, 7, 30, 90, len(grid) - 1): print(f"{day_of(grid[day])} cosine with the first centre {drift[day]:.2f} mass {mass[day]:5.1f}")2022-02-08 cosine with the first centre 1.00 mass 1.9 2022-02-15 cosine with the first centre 0.53 mass 9.6 2022-03-10 cosine with the first centre 0.54 mass 22.2 2022-05-09 cosine with the first centre 0.44 mass 6.3 2022-08-29 cosine with the first centre 0.34 mass 1.0
The Ukraine node was born on 8 February 2022 from a single item of the prelude. In a week its centre had turned far from that item (cosine 0.53); it then held steady through the invasion, and kept drifting slowly as the war moved on, until its last items in August. The node followed the story; no new node was needed for each phase. The same curve for the three nodes:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(7, 2.6))for label, node in nodes.items(): grid, centre, mass = history.trajectory(node, every=24) ax.plot((grid - grid[0]) / 24, centre @ centre[0], label=f"{label} (node {node})")ax.set(xlabel="days since the node was born", ylabel="cosine with first centre")ax.legend(frameon=False)fig.savefig("drift.svg", bbox_inches="tight")Concentration over time
Section titled “Concentration over time”History.statistics returns mass, concentration and centre at any times, recomputed with the memory’s own formulas. The Ukraine node never reached the cap: its κ stayed around 200, a broad node for a story with many fronts.
times = hours_at("2022-02-10") + 24 * np.arange(0, 60, 10)mass, kappa, centre = history.statistics(nodes["Ukraine"], times)for t, m, k in zip(times, mass, kappa): print(f"{day_of(t)} mass {m:5.1f} kappa {k:5.0f}")2022-02-10 mass 2.6 kappa 212 2022-02-20 mass 8.6 kappa 264 2022-03-02 mass 50.8 kappa 207 2022-03-12 mass 19.7 kappa 195 2022-03-22 mass 15.2 kappa 198 2022-04-01 mass 15.4 kappa 219
To see every node at once, day by day, open the memory explorer.