Abstract
Deploying machine learning on resource-constrained microcontrollers (MCUs) requires a delicate balance between predictive accuracy and energy consumption. While Random Forests (RFs) are computationally efficient, standard implementations execute the entire ensemble for every input, leading to significant energy waste on "easy" classification tasks. This paper proposes an adaptive early-stopping mechanism for RFs that monitors the confidence of aggregated predictions at runtime. By terminating inference early when a sufficient confidence threshold is met, the proposed method achieves energy savings between 38% and 90% across diverse IoT datasets with negligible impact on accuracy (<0.5%).
Introduction
Machine Learning at the "edge"—specifically on tiny Internet of Things (IoT) devices—is fundamentally constrained by battery life. While Deep Learning (DL) models offer high performance, their computational requirements often exceed the capabilities of simple microcontrollers. Random Forests are a popular alternative due to their hardware-friendly nature. However, a hidden inefficiency exists: standard RFs treat every input with equal suspicion, executing every decision tree in the forest regardless of the input's complexity.
In many real-world scenarios, a large portion of inputs are statistically "easy" to classify. A small subset of trees may be sufficient to reach a correct conclusion, while the remaining trees merely confirm the existing consensus at the cost of precious battery cycles. The challenge lies in developing an "early exit" strategy that is lightweight enough to run on an MCU without the overhead of the stopping logic negating the energy gains.
Proposed Method: Adaptive Random Forests
The authors introduce Adaptive Random Forests, which utilize a runtime-controllable confidence threshold to enable early termination of the inference process.
Aggregated Score Margin (SM)
The core innovation is the use of the ensemble's collective confidence as a stopping signal. Unlike previous methods that might evaluate the output of a single tree, this approach calculates the "Score Margin"—the difference between the probability of the most likely class and the second most likely class—based on the cumulative output of all trees executed up to that point.
If the margin exceeds a predefined threshold ($\alpha$), the forest stops and returns the current leading class. This aggregation smooths out the noise from individual trees, which might be "confident but wrong," providing a much more reliable signal for early exit.
Tree Batching and MCU Optimization
To minimize the computational overhead of calculating the Score Margin, the authors introduce "tree batching." Instead of checking the stopping condition after every tree, the model executes a batch of $B$ trees (e.g., 2 or 4) before performing the check. This reduces the frequency of the comparison logic, ensuring that the "is it time to stop?" math does not consume more energy than it saves.
Furthermore, the implementation is optimized for MCUs by using flat arrays to store the forest structure, improving memory locality. All features and thresholds are quantized to 16-bit integers, allowing the model to run efficiently on devices without a Floating Point Unit (FPU).
Experimental Evaluation
The method was evaluated on three classification tasks relevant to wearable and IoT applications:
- ECG5000: Binary anomaly detection in Electrocardiogram signals.
- Ninapro DB1: Recognition of 14 hand movements using Electromyography (EMG) signals.
- UniMiB SHAR: Classification of 17 human activities using tri-axial accelerometer data.
Key Results and Discussion
The proposed Adaptive RF was deployed on a PULPissimo (a 32-bit RISC-V MCU). The results demonstrate that the "Aggregated SM" approach consistently breaks the linear relationship between model size and energy cost by optimizing for the common "easy" case.
As shown in the performance curves, the Aggregated SM method (with batch size $B=1$) reaches the accuracy plateau much faster than a standard Random Forest. On the ECG5000 dataset, this translated to a 90% energy reduction with less than 0.5% accuracy loss. Even on the more complex Ninapro gesture recognition task, the method achieved a 38% energy saving while maintaining full baseline accuracy. The approach also proved superior to the QWYC (Quit When You Can) algorithm, particularly in multi-class scenarios.
Conclusion and Future Work
Adaptive Random Forests provide a robust framework for energy-efficient inference on the edge. By leveraging the collective confidence of the ensemble, the system can dynamically adjust its computational effort based on the difficulty of the input.
Future research directions include:
- Tree Ordering: Sorting trees by informativeness to enable even earlier exits.
- Dynamic Thresholding: Automatically adjusting the confidence threshold ($\alpha$) based on real-time battery levels or environmental context.
- Parallelization: Extending the implementation to multi-core IoT processors for further latency improvements.
Summary updated