Bench appliance classifier for predictive load admission
This model names a small DC appliance (a motor, a pump or a television) from the first second of its turn-on current. It is the appliance-recognition step of a predictive load-admission controller for small solar-battery systems, built at Soroti University, Uganda. A smart socket lets a new appliance run for one second as a test, this model names it, and the controller then answers ALLOW, DELAY or REJECT from the state of the battery.
This is a research prototype, trained on one bench rig on one day. Please read "Limitations" before you use it.
What goes in and what comes out
- Input: one second of the current (A) and the bus voltage (V), sampled 2000 times a second, recorded while a relay closes and the appliance turns on. The current of everything that was already running is subtracted first, so the recording shows only the new appliance.
- Features:
features.pyturns the recording into ten numbers, after a 5-sample median that removes single-sample ADC spikes: steady current, peak of the 10 ms average, inrush ratio, settling time, relative and absolute ripple, ripple frequency, steady power, voltage sag, and the surge above the steady current. - Output: a probability for each of three classes:
| Class | Appliance (as recorded) |
|---|---|
dc_motor |
130 DC motor on the 6.0 V output of a buck converter, free-running |
dc_tv |
12 V DC television connected to the 12 V bus, probed in standby (its own power button was not pressed) |
water_pump |
6 V pump, submerged in water, on the 6.0 V output of the buck converter |
How to use
Only numpy is needed.
from predict import BenchClassifier
from features import load_probe_csv
clf = BenchClassifier()
i_a, v_v = load_probe_csv("examples/dc_tv_010.csv") # CSV with header t_s,i_a,v_v
print(clf.classify(i_a, v_v)) # ('dc_tv', 0.89, {'dc_motor': 0.05, 'dc_tv': 0.89, 'water_pump': 0.06})
python predict.py names the three bundled example recordings. The project treats a confidence below 0.6 as "unknown appliance" (labels.json).
The file format (and why it is not a pickle)
model.npz holds the scikit-learn model as plain arrays: 5 random forests of 120 trees each, a sigmoid (Platt) calibration per class after each forest, averaged. It is read with allow_pickle=False, so opening it cannot run code (a .pkl or .joblib file can). predict.py repeats scikit-learn's arithmetic with numpy. Checked against the scikit-learn model: the same class on all 104 training events and on 3000 random feature vectors (also outside the training range), with a largest probability difference of 2e-16.
Training data
104 one-second turn-on recordings: 30 motor, 44 television and 30 pump events, recorded on 2026-11-20 on one bench rig (a 12 V, 10 Ah lead-acid battery; an ACS712-05B current sensor read by an ESP32; relays switching each appliance). The 12 V supply was varied slightly by connecting and disconnecting a bulb. The full data set (140 recordings, including a pilot with the pump and motor together and 5 excluded events) is on Zenodo. Version 2, https://doi.org/10.5281/zenodo.24414257, holds the same recordings plus every probe of the live tests below; version 1, https://doi.org/10.5281/zenodo.24401724, holds the recordings only. Three of the recordings are bundled in examples/.
Training procedure
Random forest, 120 trees, minimum leaf size 2, seed 0, with 5-fold sigmoid calibration (CalibratedClassifierCV). Training takes seconds. train.py rebuilds model.npz from the Zenodo recordings (it needs numpy and scikit-learn): download and unzip either version of the data set, then run python train.py edgeml_bench_recordings_v2 (or ..._v1). With scikit-learn 1.5.0 the rebuilt file is byte-identical to the one shipped here, from either version.
Evaluation
All numbers are from the 104 recordings above.
| Test | Result |
|---|---|
| 5-fold cross-validation | accuracy 1.000, macro-F1 1.000 |
| Train on the lower supply level, test on the higher, and the reverse | accuracy 1.000 both ways |
| Train on the early events, test on the late events, and the reverse | accuracy 1.000 both ways |
The cross-validation and the two harder splits were run with the project's own code and are described in the paper; train.py does not repeat them. Every class has precision 1.000 and recall 1.000 in cross-validation. This is an easy problem: the three appliances differ strongly in their turn-on current, so a perfect score here says little about similar appliances, other sensors or other homes.
Confidence. The calibrated model is deliberately modest: its confidence is 0.80 to 0.89 on the training events even when the class is certain, because the classes separate perfectly in the training data. In cross-validation the expected calibration error is 0.15 for the calibrated forest against 0.02 for the uncalibrated one, so the confidence is under-confident rather than over-confident. Treat it as an ordering, not as a probability of being right.
Live test. On 2026-11-21 the model ran live on the same rig, naming every new probe before the controller decided: all 80 requests were named correctly (television 23, pump 32, motor 25; confidence 0.64 to 0.89, median 0.86), 62 with the 12 V bulb off and 18 with it on, including 12 appliances requested while another one was running. These live probes are not part of the training data.
On a microcontroller, deciding live. The same model, written in C, then ran on an ESP32 decision node that receives each probe over Wi-Fi (MQTT), names the appliance and makes the admission decision itself, with no laptop in the decision path. Compiled for a PC, the C code gave the same class as predict.py for all 241 recorded and live probes (probabilities within 2e-10). On the bench the decision node named all 17 live requests correctly.
Speed. About 19 ms per recording with predict.py on a laptop (features and 5 forests, numpy only). On an ESP32 (240 MHz), the same features and forests written in C take about 96 ms (92 ms for the features with the ripple spectrum in single precision, 4 ms for the forests) and 81 kB of flash, and gave the same class as predict.py for six live probes, with probabilities equal to within 1e-10. Inside the decision node firmware, naming an appliance takes about 105 ms.
Intended use
- Research and teaching on appliance identification, non-intrusive load monitoring and edge machine learning with low-cost sensors.
- A reference implementation of the appliance-recognition step described in the accompanying paper (a manuscript at the time of writing, see "Citation").
Limitations and out-of-scope use
- One rig, one day, one sensor chain (ACS712-05B, 185 mV/A, read through the 12-bit ADC of an ESP32). Other sensors, sampling rates, wiring or supply voltages need new recordings and a new model.
- Three appliances only, and no "unknown" class. An unfamiliar appliance is forced into one of the three classes. A low confidence is the only warning, and it is not reliable for appliances unlike the training data.
- The
dc_tvclass is the standby signature of a one-second probe. The relay closes, the television enters standby and draws a very short surge and then about 0.26 A. A television that is already running (about 1.6 to 1.7 A, 18 to 20 W) was recorded separately as steady captures, not as probes, so this model is not expected to recognise it. - Appliances switched on together (the pump with the motor) are not covered. An appliance added while another one is running was tested live (12 of 12 named correctly; the socket subtracts the running current before the probe), but only for these three low-power appliances.
- Not a safety device. In the system, safety does not depend on this model: a fuse, a current abort at 4.8 A for 20 ms, a 10 s decision time-out and a conservative default for unknown appliances protect the battery whatever the classifier says.
- Mains-voltage (AC) appliances are out of scope.
Files
| File | What it is |
|---|---|
model.npz |
The calibrated random forest as numpy arrays (15 kB) |
predict.py |
BenchClassifier: loads the arrays and classifies (numpy only) |
features.py |
The ten features and the CSV reader (numpy only) |
train.py |
Rebuilds model.npz from the Zenodo recordings (numpy and scikit-learn) |
labels.json |
Class order, feature names, the 0.6 "unknown" threshold |
examples/ |
One recording of each class, from the data set |
Authors
Joseph Walusimbi, Ritah Kobusinge and Patience Clare Esaete, Department of Electronics and Computer Engineering, Soroti University, Soroti, Uganda.
Citation
Data set: J. Walusimbi, R. Kobusinge, and P. C. Esaete, "Bench turn-on recordings and live admission tests of a DC motor, a pump and a television for predictive load admission (v2)," Zenodo, Nov. 2026, doi: 10.5281/zenodo.24414257. (Version 1, recordings only: doi: 10.5281/zenodo.24401724.)
Paper: J. Walusimbi, R. Kobusinge, and P. C. Esaete, "Predictive Load Admission for Solar-Battery Systems Using Edge Machine Learning," manuscript, 2026.