Skip to content

Signals: data in, and what to do with it, one sample at a time

Everything that comes before a model lives in the folder core/signals: the files, bags and arrays that become a stream of readings, the streams made on purpose to test a model, the statistics that keep a few numbers for everything seen so far, the preprocessing that puts raw readings on a common scale, and the vision tools that read a video one frame at a time.

The map of signals

Click a page to open it, or the job on the left (or the button at the top) to go back to the map of the library.

Gamestory

London, deep night. Before the young detective can even solve a case, he has to bring order to the police station's Mailroom: every second, telegrams, recorded tapes, and photos arrive from streets all over the city, all mixed up and one piece at a time!

To prepare the clues before thinking them through, the detective sets up four worktables (Signals):

  • 1. The conveyor belt (Streams): Messages arrive from different places (old CSV logs, robot ROS tapes, and lists of numbers) at uneven times. This table lines them all up in time order, like a single continuous stream!
  • 2. The practice tracks (Datasets): Before heading out into the streets, the detective uses specially made fake heists where a breakdown or a trick change happens at exact minute n, to train his reflexes.
  • 3. The summary notebook (Statistics and RunningMoments): Instead of keeping endless piles of the day's payment receipts (120, 80, 100...), the assistant uses RunningMoments: he glances at each receipt on the fly, updates only two little numbers on his sheet — the average (mean) and how much the numbers bounce around (var) — and immediately tosses the receipt!
  • 4. The scale to put everyone on equal footing (Preprocessing): One clue talks about millions of pounds and another about a few seconds. On this table they get resized to the same scale, so giant numbers don't hide tiny ones.

In the end, what is the Signals (core/signals) section? It is all the prep work that happens before the model's brain: it gathers raw data one piece at a time, puts it in time order, summarizes it without filling up memory, and cleans it up so it is ready to study!

A first example: the payments of a day

A bank receives payments one at a time and wants their average and their spread without keeping the list. RunningMoments keeps a few numbers and updates them with each payment. Five payments of 120, 80, 100, 95 and 105:

from dense_armor.core.signals.stats.moments import RunningMoments

m = RunningMoments()
for amount in [120.0, 80.0, 100.0, 95.0, 105.0]:
    m.learn_one({"x": amount})
print(m.mean, m.var)
100.0 212.5

The mean is 100.0 and the variance 212.5 (the variance of a sample, with the divisor n - 1). The same two numbers would come from the whole list, but RunningMoments never stored it: it is the idea of every tool of the section.

The pages of the section

Page What it is for
Streams CSV files, ROS bags and arrays as one stream of readings, merged by time
Datasets streams whose change or fault happens at a known moment, to test a model
Statistics running moments, quantiles, sketches and the other numbers that summarise a stream
Preprocessing raw readings on a common scale, and speed, acceleration and power from them
Video a video read one frame at a time, in fixed memory, with no pretrained model; in the menu it sits next to Audio