StressSensein 5.77 KB
A stress-detection model that runs on the phone itself. I trained a strong gradient-boosting model, then distilled it into an INT8 TensorFlow Lite model small enough to ship inside the app.
Read this firstThe interesting part isn't the accuracy. It's what the model gave up to fit in a phone, and how little that cost.
Sensor reading to on-device prediction
Training happens once on a laptop; the trained student then runs on every reading, inside the phone. Click a stage to read what happens there.
Fast enough to disappear inside one frame
A phone redraws the screen about every 16.7 ms at 60 Hz. One prediction takes under 1.8 ms, so the app can run the model more than nine times before the user would notice a dropped frame.
Why on-deviceNo server round trip, works offline, and the user's data never leaves the phone.
Measure<1.8 ms is the measured upper bound per prediction.
Teach a small model to copy a big one
Gradient-boosted trees were the most accurate model, but a forest of trees is too heavy to ship. So the trees became the teacher: a small student learned from the teacher's predictions, then was quantized to 8-bit integers.
Trade-offThe student keeps 97.5% of the teacher's accuracy: 2.3 points lost.
Honest scaleThe bars start at zero on purpose. On a cropped axis the gap would look ten times bigger than it is.
This is the whole model
Each dot below is one byte of the shipped model, about 5,900 bytes in total. Hover to read a position. An old 1.44 MB floppy disk would hold roughly 249 copies.
Why INT8Storing weights as 8-bit integers instead of 32-bit floats makes them four times smaller and faster on mobile CPUs.
Six stages, end to end
The same six stages as the homepage. Dashed rows are still being written up.
NextAdd the evaluation split, a confusion matrix, and a short screen recording of the app.