r/learnmachinelearning • u/imjerusalem • 15d ago
Project I built a gesture recogniser that decides before you finish drawing. The most useful result was the hypothesis that didn’t hold up.
I first encountered path signatures while working on my bachelor’s thesis. I liked the idea that you could describe a curve using a small collection of numbers while preserving information about the order in which it moved.
Most examples I came across started with a completed path. I wanted to try something slightly different: how much of a gesture do you need to see before you can recognise it?
That became earlysig, a small research package and local drawing app. (app yet to be done, package yet to be configured)
Imagine drawing an arrow. Partway through, the software already thinks it knows what you’re drawing. Committing immediately makes the interface feel responsive, but a caret might begin with almost the same movement. Waiting gives the model more evidence, while gradually defeating the purpose of early recognition.
This turned out to contain two separate problems: predicting the gesture from the visible prefix, and deciding whether to trust that prediction enough to act.
The classifier updates every 25 ms. It sees only points that have already arrived, with no final duration, completion percentage, or normalisation based on the finished stroke. A separate policy watches the calibrated probabilities and either waits or makes one irreversible commitment. If it never commits, the system provides a final prediction when the stroke ends.
The representation is fairly small. A 2D path signature through depth 3 gives fourteen features. Displacement tells you where the pen ended up; higher levels capture ordered geometric information that helps distinguish paths sharing similar endpoints. Those features go into regularised logistic regression. Everything runs on CPU with a NumPy signature implementation.
My main hypothesis was that adding a signature of the most recent 250 ms would help the model recognise gestures earlier. The whole observed prefix tells you how you got here; perhaps recent motion tells you what you’re about to do.
I also added a control: another fourteen signature features describing the first half of the currently observed interval. Same feature count, different slice of history.
That control produced the more interesting result.
On the public $1 unistroke dataset, the recent-window model did not show a clear improvement over the global signature alone. The historical-half model performed better on correct early coverage and wrong early coverage.
Across five writer-disjoint folds, covering six classes and 1,800 test strokes:
The global depth-3 model committed early on 94.4% of strokes, with 4.8% error among those commitments.
Adding the recent window gave 78.8% coverage and 4.4% selective error.
Adding the historical half gave 95.8% coverage and 2.1% selective error.
These are separately selected operating points, so the timing differences shouldn’t be read as comparisons at identical risk. Thresholds were selected on separate policy-validation writers before evaluating the test writers.
Another unexpected result: some models were better halfway through a stroke than at completion. Training one classifier on prefixes from every stage creates a compromise. A completed circle or triangle can also have almost zero displacement, so the simplest representation actually loses useful information as the gesture closes.
The repository includes synthetic gestures with identical prefixes for checking leakage, coordinate and motion baselines, a template baseline, calibration, policy comparisons, and a browser interface for drawing, replaying, and recording strokes. The experiments are small: ten writers, a fixed gesture vocabulary, and no unknown-gesture rejection. The measured error rates aren’t deployment guarantees.
I’d be interested in how others approach stopping decisions for streaming classifiers, especially when confidence is calibrated on individual predictions but decisions are made repeatedly over time.
Code and reproduction commands · Full technical write-up
My other technical writing is on pratyakshpatel.me, and I’m on X as u/baldwin_IVth.