Name | sklearn2c JSON |
Version |
0.0.4
JSON |
| download |
home_page | None |
Summary | A simple tool to embed scikit-learn models into microcontrollers |
upload_time | 2024-10-27 19:16:44 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2022 EmbeddedML Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
embedded
machine learning
scikit-learn
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Machine Learning for Embbedded Devices
sklearn2c is a tool that converts scikit-learn library classification algorithms to C code. It can be used to generate C code from trained models, which can then be used in microcontrollers or other embedded systems. The generated code can be used for real-time classification tasks, where the computational resources are limited.
## Supported Models
### Classification
- Bayes Classifier*
- Decision Trees
- KNN Classifier
- C-SVC**
*: sklearn2c does not use scikit-learn `GaussianNB()`, instead it uses the following cases to compute decision function.
**: `linear`, `poly` and `rbf` kernels are supported.
### Regression
- Linear Regression
- Polynomial Regression
- KNN
- Decision Trees
### Clustering
- kmeans
- DBSCAN
## Installation
You can install the library via pip either using:
`pip install sklearn2c`
or
`pip install git+git@github.com:EmbeddedML/sklearn2c.git`
Alternatively, you can install conda package:
`conda install sklearn2c` or `mamba install sklearn2c`
## Usage
Please check `examples` directory under this repository. For example, decision tree classifier is created as follows:
- `train` method trains the model and optionally saves the model file to `save_path`. This method is totally compatible with scikit-learn library.
- `predict` method runs the model on the given data.
- static method `load` loads the model from saved path.
- `export` method generates model parameters as C functions.
```
dtc = DTClassifier()
dtc.train(train_samples, train_labels, save_path="<path/to/model>")
dtc.predict(test_samples)
dtc2 = DTClassifier.load(dtc_model_dir)
dtc2.export("<path/to/config_dir>")
```
For inference on C(specifically for STM32 boards), you can take a look at `STM32_inference` directory for the corresponding model.
## License
[MIT](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "sklearn2c",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "EmbeddedML <berkanh@gmail.com>",
"keywords": "embedded, machine learning, scikit-learn",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/71/09/416b9776445c8dbfecb7d25cddc0e5da27ada10c10415d15b19ebf95ed94/sklearn2c-0.0.4.tar.gz",
"platform": null,
"description": "# Machine Learning for Embbedded Devices\r\nsklearn2c is a tool that converts scikit-learn library classification algorithms to C code. It can be used to generate C code from trained models, which can then be used in microcontrollers or other embedded systems. The generated code can be used for real-time classification tasks, where the computational resources are limited.\r\n\r\n## Supported Models\r\n### Classification\r\n- Bayes Classifier*\r\n- Decision Trees\r\n- KNN Classifier\r\n- C-SVC**\r\n \r\n *: sklearn2c does not use scikit-learn `GaussianNB()`, instead it uses the following cases to compute decision function.\r\n \r\n **: `linear`, `poly` and `rbf` kernels are supported.\r\n### Regression\r\n- Linear Regression\r\n- Polynomial Regression\r\n- KNN\r\n- Decision Trees\r\n### Clustering\r\n- kmeans\r\n- DBSCAN\r\n\r\n## Installation\r\nYou can install the library via pip either using:\r\n\r\n`pip install sklearn2c`\r\n\r\nor\r\n\r\n`pip install git+git@github.com:EmbeddedML/sklearn2c.git`\r\n\r\nAlternatively, you can install conda package:\r\n\r\n`conda install sklearn2c` or `mamba install sklearn2c`\r\n\r\n## Usage\r\n\r\nPlease check `examples` directory under this repository. For example, decision tree classifier is created as follows:\r\n- `train` method trains the model and optionally saves the model file to `save_path`. This method is totally compatible with scikit-learn library. \r\n- `predict` method runs the model on the given data.\r\n- static method `load` loads the model from saved path.\r\n- `export` method generates model parameters as C functions.\r\n\r\n```\r\ndtc = DTClassifier()\r\ndtc.train(train_samples, train_labels, save_path=\"<path/to/model>\")\r\ndtc.predict(test_samples)\r\ndtc2 = DTClassifier.load(dtc_model_dir)\r\ndtc2.export(\"<path/to/config_dir>\")\r\n```\r\nFor inference on C(specifically for STM32 boards), you can take a look at `STM32_inference` directory for the corresponding model.\r\n\r\n## License\r\n[MIT](LICENSE)\r\n\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2022 EmbeddedML Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A simple tool to embed scikit-learn models into microcontrollers",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/EmbeddedML/sklearn2c",
"Issue Tracker": "https://github.com/EmbeddedML/sklearn2c/issues/"
},
"split_keywords": [
"embedded",
" machine learning",
" scikit-learn"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b935857934de3940f81588daea0c434c6df792b80b4d6ee9e5714b386b062031",
"md5": "60a136a5198bf1c8bc6212939e7962e8",
"sha256": "9878538a51b9ac5b029d1a6fd69a9302189e31bcdc0bd159ef07c0671040156c"
},
"downloads": -1,
"filename": "sklearn2c-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "60a136a5198bf1c8bc6212939e7962e8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 17707,
"upload_time": "2024-10-27T19:16:42",
"upload_time_iso_8601": "2024-10-27T19:16:42.367269Z",
"url": "https://files.pythonhosted.org/packages/b9/35/857934de3940f81588daea0c434c6df792b80b4d6ee9e5714b386b062031/sklearn2c-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7109416b9776445c8dbfecb7d25cddc0e5da27ada10c10415d15b19ebf95ed94",
"md5": "92934b5482159204e465e77f22d39479",
"sha256": "149a0ea65ca054ffefc3ccf4d39e0f3538ce6ef6a3b81c1a34315be45aba5556"
},
"downloads": -1,
"filename": "sklearn2c-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "92934b5482159204e465e77f22d39479",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 11657,
"upload_time": "2024-10-27T19:16:44",
"upload_time_iso_8601": "2024-10-27T19:16:44.145354Z",
"url": "https://files.pythonhosted.org/packages/71/09/416b9776445c8dbfecb7d25cddc0e5da27ada10c10415d15b19ebf95ed94/sklearn2c-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-27 19:16:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "EmbeddedML",
"github_project": "sklearn2c",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sklearn2c"
}