All the cool kids like Bosch and ST Microeletronics are already integrating machine learning and on-chip-training(they call it 'self-learning') into their products. (BMI360/BMI380 from Bosch and NanoEdgeAI from ST Microeletronics) Unfortunately the algorithms are hidden behind seven locks.
So, I decided to write my own little Arduino library for on-chip training. The library is called TinyDecisionTreeClassifier and it's interface mimics DecisionTreeClassifier from sci-kit learn.
What can it do? Well, it helps to automatically classify the data (after the model was trained). I tested the activity recognition (sit/walk/stand), but it would be quite interesting to check, if it can be used for classifying machinery failure based on vibration or for human stress detection from PPG (As in smartwaches). My guess is that it would work. The library is now available from PlatformIO registry or from my github under Apache-2.0 license ('do whatever you want' license).
So, this week I decided to test the TinyDecisionTreeClassifier with my fan to see if it can recognize the 'broken' fan movement.
Nothing fancy, one minute of training data for each state(ok/failure), then few seconds of training process, then it can magically recognize the state. Also, I had to increase the accel sampling frequency to 50 Hz. I used Nrf52840, but it should work with any Arduino-compatible MCU that has enough SRAM(like Esp32).