TinyML Unknown Gestures: Use an Anomaly Score Without Mistaking It for Class Confidence

A motion classifier can assign an unfamiliar movement a familiar gesture label. Raising the class threshold may reject some cases, but it does not directly ask whether the input resembles the training distribution. An anomaly block adds a different observation that the application should retain separately from its class scores.

The concrete mechanism here is Edge Impulse’s K-means anomaly block and motion-recognition tutorial, as documented on 19 October 2026. This is a proposed gesture-rejection design for a microcontroller application. No data was collected, model trained or deployment executed.

Keep the two questions visible

A classifier ranks known labels. An anomaly model examines how the selected input features relate to the normal examples it learned. The outputs can disagree without either interface being broken: an unfamiliar movement can strongly resemble one class relative to the other available labels while remaining far from the known feature clusters.

For a harmless user-interface gesture fixture, keep three outputs in the diagnostic record: the leading class, that class’s score and the anomaly score. Add the final accept/reject decision as a fourth field. A log that preserves only the accepted class erases the evidence needed to explain a rejection.

Do not rename the anomaly score “unknown probability.” The K-means block description says the deployed score measures distance from the closest cluster’s edge, using stored cluster center and size. A point inside a cluster can have a negative score. That sign convention and scale are specific to this block; they must not be transferred to a different anomaly algorithm by name alone.

A feature window produces class and anomaly scores; high class confidence can still be rejected for excessive anomaly distance.
Original decision worksheet. It depicts a proposed gate, not measured model performance.

Define normal motion before selecting axes

The K-means configuration selects a cluster count and generated-feature axes. Those axes come from preprocessing. They are not necessarily raw accelerometer X, Y and Z samples, even if their names mention those channels.

Write the normal-input envelope for the gesture interface: intended mounting, user movements, operating orientations and background handling. Train the normal clusters from that agreed envelope. The documentation warns that anomalies should not be included in the normal training set and that some outliers can still fit inside learned clusters.

A practical feature review compares known gestures with several plausible non-gestures, then asks which generated features preserve the difference. The tutorial’s shake example demonstrates this investigation; it does not establish that every shake or every unknown movement is separable on every product.

Processing-block documentation explains optional normalization learned from feature-column means and standard deviations and applied during training and inference. Keep the exported preprocessing and normalization with the model. Changing feature scaling changes the geometry being scored; retaining the old numeric anomaly threshold after such a change requires renewed evidence.

Make rejection an explicit application rule

A simple proposed decision rule for the harmless fixture is:

accept the leading known label only when
    class_score >= class_threshold
    and anomaly_score <= anomaly_threshold
otherwise emit no recognized gesture

This is an application policy, not an Edge Impulse guarantee or a calibrated probability formula. Choose both thresholds from relevant validation observations and preserve the comparison boundaries. Do not copy the tutorial’s cluster count or a screenshot threshold as a product constant.

Inspect four cases in a decision worksheet. High class score with acceptable anomaly score may pass. High class score with excessive anomaly score must be rejected by this policy. Low class score remains rejected even when the input is close to a normal cluster. Low class score with excessive anomaly score also rejects.

The second case is the important negative control: it proves the application actually consults the anomaly result rather than printing it beside a decision made only from the classifier. The third case prevents the opposite mistake, treating familiar-looking input as sufficient to identify a particular gesture.

Evaluate misses and unwanted accepts separately

Propose a held-out fixture containing normal gesture variations, unfamiliar movements and ambiguous boundary windows. Retain the raw recording identity, generated features, both outputs and final decision. Include naturally still and handled-but-not-commanded conditions relevant to the interface.

Report rejected valid gestures separately from accepted non-gestures. Combining them into one accuracy percentage can conceal a threshold that appears selective only because it rejects almost everything. Review failures by movement type and operating condition before changing the cluster count or threshold.

An anomaly rejection identifies a mismatch to learned normal behavior. It does not diagnose a named mechanical fault, malicious input or a specific new gesture. An unknown movement accepted by the gate remains a failure case to examine, not proof that the movement has become normal by definition.

Finally, repeat the frozen decision fixture through the exported microcontroller pipeline, preserving acquisition timing and feature processing. Host-side separation is useful design evidence but cannot establish target-side behavior on its own. The result to establish is a bounded recognition policy with understandable rejections, not universal unknown-motion detection or a safety function.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *