Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Edge_intelligence packages and examples #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions examples/edge_intelligence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Edge Intelligence Models

This folder contains [PFA](http://dmg.org/pfa/docs/motivation/), [scikit-learn](http://scikit-learn.org/) and [TensorFlow](https://www.tensorflow.org/) and RuleEdgeComponent examples.
Trained PFA, scikit-learn and TensorFlow models are present under the trained_models directory.
The generated data is using the [TI SensorTag](http://www.ti.com/ww/en/wireless_connectivity/sensortag/) which has been used for training the windmill model.
It provides a basic example which uses TI SensorTag data to simulate a sample windmill model. The basic metrics we collect from Windmill model using TI SensorTag are:
- RPM
- Vibration
- Ambient Temperature
- Relative Humidity.

The files ```windmill_tf_train.csv``` and ```windmill_tf_test.csv``` in trained_models directory are used for training and testing of accuracy of the TensorFlow model respectively.
The file ```windmill_tf_model.py``` in trained_models directory is imdependent of Liota and used for creating the trained TensorFlow model and testing it's accuracy and prediction.

# RuleEdgeComponent

Rule edge component is one of the edge intelligence components provided by Liota, you can define a simple rule depending on your requirement as a [python lambda](https://www.python-course.eu/lambda.php) function and the rule edge component will process the incoming metrics and the result can be passed onto actuator on basis of the rule you have defined as lambda function.

Currently tested for one metric only.

# Example
If you have to take rpm as a metric and if rpm exceeds certain limits you have to perform some action, you can define a lambda function as:
```
Rule = lambda rpm : 1 if (rpm>=rpm_limit) else 0
```
Now just create the ruleEdge and pass it onto RuleEdgeComponent along with the actuator_udm and exceed_limit.
actuator_udm can be used to pass on the value to the actuator, as of now we are printing them, here udm stands for user defined method.
exceed_limit is a parameter which can be specified about after how many times the limit is exceeded then action should be taken.
Example: If rpm exceeds rpm_limit consecutively exceed 3 times then only action should be applied, in that case we would assign exceed_limit = 3
```
edge_component = RuleEdgeComponent(ModelRule,exceed_limit,actuator_udm=action_actuator)
```
After this register the edge_component and start_collecting the values from sensor.
The values which will get published to RuleEdge component. Please refer the example file windmill_graphite_rule.py.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@": "PrettyPFA document", "name": "Engine_1", "input": "double", "output": "double", "method": "map", "action": [{"@": "PrettyPFA line 14", "let": {"baseLL": {"@": "PrettyPFA line 14", "prob.dist.gaussianLL": ["input", {"@": "PrettyPFA line 14", "cell": "baseline", "path": [{"@": "PrettyPFA line 14", "string": "mu"}]}, {"@": "PrettyPFA line 14", "cell": "baseline", "path": [{"@": "PrettyPFA line 14", "string": "sig"}]}]}}}, {"@": "PrettyPFA line 15", "let": {"altLL": {"@": "PrettyPFA line 15", "prob.dist.gaussianLL": ["input", {"@": "PrettyPFA line 15", "cell": "alternate", "path": [{"@": "PrettyPFA line 15", "string": "mu"}]}, {"@": "PrettyPFA line 15", "cell": "alternate", "path": [{"@": "PrettyPFA line 15", "string": "sig"}]}]}}}, {"@": "PrettyPFA lines 16-17", "cell": "cusum", "to": {"params": [{"old": "double"}], "ret": "double", "do": [{"@": "PrettyPFA line 17", "stat.change.updateCUSUM": [{"@": "PrettyPFA line 17", "-": ["altLL", "baseLL"]}, "old", {"@": "PrettyPFA line 17", "cell": "reset"}]}]}}], "cells": {"cusum": {"@": "PrettyPFA line 8", "type": "double", "init": 0.0, "shared": true, "rollback": false}, "reset": {"@": "PrettyPFA line 9", "type": "double", "init": 0.0, "shared": false, "rollback": false}, "alternate": {"@": "PrettyPFA line 11", "type": {"fields": [{"type": "double", "name": "mu"}, {"type": "double", "name": "sig"}], "type": "record", "name": "Record_1"}, "init": {"mu": 24.23076923076923, "sig": 9.420276925706693}, "shared": false, "rollback": false}, "baseline": {"@": "PrettyPFA line 10", "type": "Record_1", "init": {"mu": 10.448598130841122, "sig": 2.0227690446443916}, "shared": false, "rollback": false}}}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
model_checkpoint_path: "model.ckpt-2000"
all_model_checkpoint_paths: "model.ckpt-1"
all_model_checkpoint_paths: "model.ckpt-2000"
Loading