SEFR Algorithm Performs Image Classification, Including Training, on an Arduino Uno or Other MCU

Now available as part of the EloquentML machine learning library, or directly as Python and C example implementations.

Researchers from the Tarbiat Modares and Boston Universities have released a linear-time high-performance image classifier designed to run on low-power devices — and Eloquent Arduino's Simone has ported the C implementation to the Eloquent Machine Learning (EloquentML) library for microcontroller users.

"One of the fundamental challenges for running machine learning algorithms on battery-powered devices is the time and energy needed for computation, as these devices have constraints on resources," the research team explains of its work on SEFR. "There are energy-efficient classifier algorithms, but their accuracy is often sacrificed for resource efficiency. Here, we propose an ultra-low power binary classifier, SEFR, with linear time complexity, both in the training and the testing phases."

"The SEFR method runs by creating a hyperplane to separate two classes. The weights of this hyperplane are calculated using normalization, and then the bias is computed based on the weights. SEFR is comparable to state-of-the-art classifiers in terms of classification accuracy, but its execution time and energy consumption are 11.02% and 8.67% of the average of state-of-the-art and baseline classifiers."

Simone spotted the SEFR paper, and faced with claims of the ability to run iris detection with just four features at one weight per feature yet achieve 100 percent accuracy — and to run all parts of the model, including training, directly on a microcontroller — worked to add the classifier to his EloquentML library.

"The authors both provided a C and Python implementation on GitHub you can read," Simone writes. "I ported the C version 'manually' to my EloquentML library and created a Python package called SEFR copy-pasting from the original repo."

In testing, Simone found that his port of SEFR could achieve 100 percent accuracy on an iris classification task with just four features, 89 percent for breast cancer classification at 30 features, 84 percent for wine at 13 features, and 99 percent accuracy for digits at 64 features. "Considering that the model only needs one weight per feature," Simone notes, "I think this results are impressive!"

"The energy and memory consumption of SEFR is very insignificant, and it even can perform both train and test phases on microcontrollers," its creators note of the original port. "We have implemented SEFR on Arduino Uno, and on a dataset with 100 records and 100 features, the training time is 195 milliseconds, and testing for 100 records with 100 features takes 0.73 milliseconds. To the best of our knowledge, this is the first multi-purpose algorithm specifically devised for learning on ultra-low power devices."

The SEFR paper is available under open-access terms on arXiv.org now; the original C and Python implementations are on GitHub under an unspecified license. Simone's Python package is available on GitHub under the permissive MIT License, or as part of the Eloquent Micro ML repository.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles