Machine learning for microcontroller and embedded systems. Train in Python, then do inference on any device with a C99 compiler.
Embedded-friendly Inference
Convenient Training
Can be used as an open source alternative to MATLAB Classification Trees,
Decision Trees using MATLAB Coder for C/C++ code generation.
fitctree
, fitcensemble
, TreeBagger
, ClassificationEnsemble
, CompactTreeBagger
Minimally useful
Classifiers:
eml_trees
: sklearn.RandomForestClassifier, sklearn.ExtraTreesClassifier, sklearn.DecisionTreeClassifiereml_net
: sklearn.MultiLayerPerceptron, Keras.Sequential with fully-connected layerseml_bayes
: sklearn.GaussianNaiveBayesUnsupervised / Outlier Detection / Anomaly Detection
eml_distance
: sklearn.EllipticEnvelope (Mahalanobis distance)Feature extraction:
eml_audio
: MelspectrogramTested running on AVR Atmega, ESP8266, ESP32, ARM Cortex M (STM32), Linux, Mac OS and Windows.
Install from PyPI
pip install --user emlearn
The basic usage consist of 3 steps:
from sklearn.ensemble import RandomForestClassifier
estimator = RandomForestClassifier(n_estimators=10, max_depth=10)
estimator.fit(X_train, Y_train)
...
import emlearn
cmodel = emlearn.convert(estimator, method='inline')
cmodel.save(file='sonar.h')
#include "sonar.h"
const int32_t length = 60;
int32_t values[length] = { ... };
const int32_t predicted_class = sonar_predict(values, length):
For full code see the examples.
Jon Nordby
Mark Cooke
If you use emlearn
in an academic work, please reference it using:
@misc{emlearn,
author = {Jon Nordby},
title = {{emlearn: Machine Learning inference engine for
Microcontrollers and Embedded Devices}},
month = mar,
year = 2019,
doi = {10.5281/zenodo.2589394},
url = {https://doi.org/10.5281/zenodo.2589394}
}
emlearn
has been used in the following works.
If you are using emlearn, let us know! You can for example submit a pull request for inclusion in this README, or create an issue on Github.
Version | Tag | Published |
---|---|---|
0.16.3 | 1mo ago | |
0.14.1 | 1yr ago | |
0.14.0 | 1yr ago | |
0.13.1 | 1yr ago |