Tiny Federated ML for Fog Computing
Project description
FogML
Due to the development of IoT solutions, we can observe the constantly growing number of these devices in almost every aspect of our lives. The machine learning may improve increase their intelligence and smartness. Unfortunately, the highly regarded programming libraries consume to much resources to be ported to the embedded processors.
The structure of the project is as follows:
- the
src
folder contains the source code generators for machine learning models i.e.: naive bayes, decision trees/forrest and neural nets; - the
example
folder contains the simple examples and the MNIST digit recognition for Arduino board and the simple TFT touchscreen.
Examples of anomaly detection and classification algorithms provided by the FogML project for embedded devices:
FogML-SDK
[https://github.com/tszydlo/fogml_sdk]FogML Arduino
[https://github.com/tszydlo/FogML-Arduino]FogML Zephyr OS
[https://github.com/tszydlo/FogML-Zephyr]
Example of connectivity and device management provided by LwM2M protocol:
FogML-Zephyr-LwM2M
[https://github.com/tszydlo/FogML-Zephyr-LwM2M]
Usage
pip install fogml
Example
from sklearn import datasets, tree
from fogml.generators import GeneratorFactory
iris = datasets.load_iris()
X = iris.data
y = iris.target
clf = tree.DecisionTreeClassifier(random_state=3456)
clf.fit(X, y)
print( 'accuracy: ',clf.score(X,y))
factory = GeneratorFactory()
generator = factory.get_generator(clf)
generator.generate()
Reinforcement Learning
import gym
from fogml.generators import GeneratorFactory
from fogml.rl.qlearning import QLearning, QStatesIntervals
env = gym.make('MountainCar-v0')
#create QStates discretizer table using QStatesIntervals()
stateSpace = [
[-1.2, 0.6, 20],
[-0.07, 0.07, 20]
]
qStates = QStatesIntervals(stateSpace)
#create QLearning agent
qAgent = QLearning(qStates.getStates(), env.action_space.n)
for episode in range(EPISODES):
#TODO Train the model
#see examples
factory = GeneratorFactory()
generatorQAgent = factory.get_generator(qAgent)
generatorQStates = factory.get_generator(qStates)
generatorQAgent.generate(fname='FogML_RL_Arduino\qlearning_model_test.c')
generatorQStates.generate(fname = 'FogML_RL_Arduino\qstates_discretizer_test.c')
See it in action: https://www.youtube.com/watch?v=yEr5tjBrY70
FogML research
If you think that the project is interesting to you, please cite the papers:
Tomasz Szydlo, Online Anomaly Detection Based On Reservoir Sampling and LOF for IoT devices, CoRR abs/2206.14265 (2022)
Tomasz Szydlo, Joanna Sendorek, Robert Brzoza-Woch, Enabling machine learning on resource constrained devices by source code generation of the learned models, ICCS 2018: 682-694
The research was supported by the National Centre for Research and Development (NCBiR) under Grant No. LIDER/15/0144 /L-7/15/NCBR/2016.
Press
https://blog.arduino.cc/2022/07/22/industrial-iot-anomaly-detection-on-microcontrollers/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fogml-0.0.7.tar.gz
.
File metadata
- Download URL: fogml-0.0.7.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da74d7ba1d2d1e0ec5843f9d8121612b8e36029cc76a4a824d395d8717303c28 |
|
MD5 | 719a37ff1095f026d1c7558d0baf8bca |
|
BLAKE2b-256 | 5436cb3d9a58e2534d573e53c7e92c1991783a5a6873055732029ca426c5fed4 |
File details
Details for the file fogml-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: fogml-0.0.7-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c6f05c76c7cde5edadd4f4a634aa584c78d0575393aa879e40ebfc1e67b4101 |
|
MD5 | 15d253c333f7c083033f5fe49bbcc561 |
|
BLAKE2b-256 | 86e47e346718f2a47ca2728fcaf420a7be6f3ef313e546f2f4880bd78da96e23 |