GithubHelp home page GithubHelp logo

gaoyiyeah / emtrees Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emlearn/emlearn

0.0 2.0 0.0 73 KB

Tree-based machine learning classifiers for embedded systems

License: MIT License

C 18.82% Python 67.20% C++ 13.98%

emtrees's Introduction

emtrees

Tree-based machine learning classifiers for embedded systems. Train in Python, deploy on microcontroller.

Want Naive Bayes instead? Go to embayes

Key features

Embedded-friendly Classifier

  • Portable C99 code
  • No stdlib required
  • No dynamic allocations
  • Integer/fixed-point math only
  • Single header file include
  • Fast, sub-millisecond classification

Convenient Training

  • API-compatible with scikit-learn
  • Implemented in Python 3
  • C classifier accessible in Python using pybind11

MIT licensed

Status

Minimally useful

  • Random Forests and ExtraTrees classifiers implemented
  • Tested running on AVR, ESP8266 and Linux.
  • On ESP8266, 8x8 digits classify in under 0.3ms with 95%+ accuracy

Installing

Install from PyPI

pip install emtrees --user

Usage

  1. Train your model in Python
import emtrees
estimator = emtrees.RandomForest(n_estimators=10, max_depth=10)
estimator.fit(X_train, Y_train)
...
  1. Generate C code
code = estimator.output_c('sonar')
with open('sonar.h', 'w') as f:
   f.write(code)
  1. Use the C code
#include <emtrees.h>
#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 arduinobench.ino

TODO

0.2

  • Standalone example application on microcontroller

1.0

  • Support serializing/deserializing trees
  • Support multi-target classification
  • Maybe implement a Very Fast Decision Tree (VFDT) learning algorithm

emtrees's People

Contributors

jonnor avatar

Watchers

James Cloos avatar GRU avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.