emlearn
Machine learning for microcontroller and embedded systems. Train in Python, then do inference on any device with a C99 compiler.
Key features
Embedded-friendly Inference
- Portable C99 code
- No libc required
- No dynamic allocations
- Support integer/fixed-point math
- Single header file include
Convenient Training
- Using Python with scikit-learn or Keras
- The generated C classifier is also accessible in Python
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
Status
Minimally useful
Classifiers:
eml_trees: sklearn.RandomForestClassifier, sklearn.ExtraTreesClassifier, sklearn.DecisionTreeClassifiereml_net: sklearn.MultiLayerPerceptron, Keras.Sequential with fully-connected layerseml_bayes: sklearn.GaussianNaiveBayes
Feature extraction:
eml_audio: Melspectrogram
Tested running on AVR Atmega, ESP8266 and Linux.
Installing
Install from PyPI
pip install --user emlearn
Usage
- Train your model in Python
from sklearn.ensemble import RandomForestClassifier
estimator = RandomForestClassifier(n_estimators=10, max_depth=10)
estimator.fit(X_train, Y_train)
...
- Convert it to C code
import emlearn
cmodel = emlearn.convert(estimator, method='inline')
cmodel.save(file='sonar.h')
- Use the C code
#include "sonar.h"
const int32_t length = 60;
int32_t values[length] = { ... };
const int32_t predicted_class = sonar_predict(values, length):
For full example code, see examples/digits.py and emlearn.ino
Metadata
Release files for emlearn 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| emlearn-0.8.1.tar.gz | 35.0 kB | Without provenance | Details for emlearn-0.8.1.tar.gz |
Release files / emlearn-0.8.1.tar.gz
| Download URL | emlearn-0.8.1.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
283da89ef890e6f1b3f31b66dd4332b89aecb9ff3811f0c80f989ba6ba97296c
|
|
BLAKE2b-256 checksum How to use checksums |
dbf44b63b598b9744662857eba9f8486bace31054ad0f81890f8d3b94afc55e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
|
Security for emlearn 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.