{"id":14958347,"url":"https://github.com/lucastsutsui/embml","last_synced_at":"2025-10-24T14:31:52.431Z","repository":{"id":57426189,"uuid":"251133149","full_name":"lucastsutsui/EmbML","owner":"lucastsutsui","description":"A tool to support using classification models in low-power and microcontroller-based embedded systems.","archived":false,"fork":false,"pushed_at":"2023-04-05T03:57:08.000Z","size":182,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-29T23:33:25.379Z","etag":null,"topics":["classification-model","classification-models","classifier","edge-computing","edge-machine-learning","embedded-systems","embml","iot-device","machine-learning","microcontroller","microcontrollers","scikit-learn","tinyml","weka"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/embml/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucastsutsui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-29T20:58:29.000Z","updated_at":"2024-02-19T15:34:39.000Z","dependencies_parsed_at":"2022-09-11T04:20:55.811Z","dependency_job_id":"78e088ac-3e02-4e9c-aca1-e016432b347b","html_url":"https://github.com/lucastsutsui/EmbML","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"d5c50e4512bca7c202af031700f139ce998336c5"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucastsutsui%2FEmbML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucastsutsui%2FEmbML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucastsutsui%2FEmbML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucastsutsui%2FEmbML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucastsutsui","download_url":"https://codeload.github.com/lucastsutsui/EmbML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237990569,"owners_count":19398452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classification-model","classification-models","classifier","edge-computing","edge-machine-learning","embedded-systems","embml","iot-device","machine-learning","microcontroller","microcontrollers","scikit-learn","tinyml","weka"],"created_at":"2024-09-24T13:16:48.986Z","updated_at":"2025-10-24T14:31:47.368Z","avatar_url":"https://github.com/lucastsutsui.png","language":"Python","readme":"\n# EmbML\n\nEmbML is a tool written in Python to automatically convert off-board-trained models into C++ (default option) or C source code files that can be compiled and executed in low-power microcontrollers. The main goal of EmbML is to produce classifier source codes that will run specifically in resource-constrained hardware systems, using bare metal programming.\n\nThis tool takes as input a classification model that was trained in a desktop or server computer using WEKA or scikit-learn libraries. EmbML is responsible for converting the input model into a carefully crafted code in C or C++ with support for embedded hardware, such as the avoidance of unnecessary use of SRAM memory and implementation of fixed-point operations for non-integer numbers. \n\n## Input Models\n\nEmbML accepts a trained model through the file that contains its serialized object. For instance, a classification model, built with WEKA, shall be serialized into a file using the _ObjectOutputStream_ and _FileOutputStream_ classes (available in Java). [Example of saving a WEKA model using its GUI.](https://machinelearningmastery.com/save-machine-learning-model-make-predictions-weka/).\n\nAs for the scikit-learn models, they shall be serialized using the _dump_ function, from _pickle_ module. An example is provided in \u003chttps://scikit-learn.org/stable/modules/model_persistence.html\u003e.\n\n## Supported Classification Models\n\n`embml` supports off-board-trained classifiers from the following classes:\n\n* From WEKA:\n\t* _MultilayerPerceptron_ for MLP classifiers;\n\t* _Logistic_ for logistic regression classifiers;\n\t* _SMO_ for SVM classifiers -- with linear, polynomial, and RBF kernels;\n\t* _J48_ for decision tree classifier.\n* From scikit-learn:\n\t* _MLPClassifier_ for MLP classifiers;\n\t* _LogisticRegression_ for logistic regression classifiers;\n\t* _LinearSVC_ for SVM classifiers with linear kernel;\n\t* _SVC_ for SVM classifiers -- with polynomial and RBF kernels;\n\t* _DecisionTreeClassifier_ for decision tree models.\n\n## Installation\n\nYou can install `embml` from [PyPi](https://pypi.org/project/embml/):\n\n```python\npip install embml\n```\n\nThis tool is supported on Python 2.7 and Python 3.7 versions, and depends on the `javaobj` library (\u003chttps://pypi.org/project/javaobj-py3/\u003e).\n\n## How To Use\n\n```python\nimport embml\n\n# For scikit-learn models\nembml.sklearnModel(inputModel, outputFile, opts)\n\n# For WEKA models\nembml.wekaModel(inputModel, outputFile, opts)\n\t\t\n# opts can include:\n#\t-rules: to generate a decision tree classifier code using a representation with if-then-else statements.\n#\t-fxp \u003cn\u003e \u003cm\u003e: to generate a classifier code that uses fixed-point format to perform real number operations. In this case, \u003cn\u003e is the number of integer bits and \u003cm\u003e is the number of fractional bits in the Qn.m format. Note that n + m + 1 must be equal to 32, 16, or 8, since that one bit is used to represent signed numbers.\n#\t-approx: to generate an MLP classifier code that employs an approximation to substitute the sigmoid as an activation function in the neurons.\n#\t-pwl \u003cx\u003e: to generate an MLP classifier code that employs a piecewise approximation to substitute the sigmoid as an activation function in the neurons. In this case, \u003cx\u003e must be equal to 2 (to use an 2-point PWL approximation) or 4 (to use an 4-point PWL approximation).\n\n# Examples of generating decision tree classifier codes using if-then-else format.\nembml.wekaModel(inputDecisionTreeModel, outputFile, opts='-rules')\nembml.sklearnModel(inputDecisionTreeModel, outputFile, opts='-rules')\n\n# Examples of generating classifier codes in C programming language.\nembml.wekaModel(inputModel, outputFile, opts='-c')\nembml.sklearnModel(inputModel, outputFile, opts='-c')\n\n# Examples of generating classifier codes using fixed-point formats.\nembml.wekaModel(inputModel, outputFile, opts='-fxp 21 10') # Q21.10\nembml.sklearnModel(inputModel, outputFile, opts='-fxp 21 10') # Q21.10\nembml.wekaModel(inputModel, outputFile, opts='-fxp 11 4') # Q11.4\nembml.sklearnModel(inputModel, outputFile, opts='-fxp 11 4') # Q11.4\nembml.wekaModel(inputModel, outputFile, opts='-fxp 5 2') # Q5.2\nembml.sklearnModel(inputModel, outputFile, opts='-fxp 5 2') # Q5.2\n\n# Examples of generating MLP classifier codes using an approximation function.\nembml.wekaModel(inputMlpModel, outputFile, opts='-approx')\nembml.sklearnModel(inputMlpModel, outputFile, opts='-approx')\n\n# Examples of generating MLP classifier codes using PWL approximations.\nembml.wekaModel(inputMlpModel, outputFile, opts='-pwl 2')\nembml.sklearnModel(inputMlpModel, outputFile, opts='-pwl 2')\nembml.wekaModel(inputMlpModel, outputFile, opts='-pwl 4')\nembml.sklearnModel(inputMlpModel, outputFile, opts='-pwl 4')\n\n# It is also possible to combine some options:\t\nembml.wekaModel(inputMlpModel, outputFile, opts='-fxp 21 10 -pwl 2')\nembml.sklearnModel(inputMlpModel, outputFile, opts='-fxp 21 10 -pwl 2')\nembml.wekaModel(inputDecisionTreeModel, outputFile, opts='-fxp 21 10 -rules')\nembml.sklearnModel(inputDecisionTreeModel, outputFile, opts='-fxp 21 10 -rules')\n```\n\n## Fixed-point library\n\nIf you decide to generate a classifier code using a fixed-point format, you need to include the `FixedNum.h` library available at [https://github.com/lucastsutsui/EmbML](https://github.com/lucastsutsui/EmbML).\n\n## Citation\n\nIf you use this tool on a scientific work, we kindly ask you to use the following reference:\n\n```tex\n@inproceedings{da2019embml,\n  title={EmbML Tool: supporting the use of supervised learning algorithms in low-cost embedded systems},\n  author={da Silva, Lucas Tsutsui and Souza, Vinicius MA and Batista, Gustavo EAPA},\n  booktitle={2019 IEEE 31st International Conference on Tools with Artificial Intelligence (ICTAI)},\n  pages={1633--1637},\n  year={2019},\n  organization={IEEE}\n}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucastsutsui%2Fembml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucastsutsui%2Fembml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucastsutsui%2Fembml/lists"}