The estimator is defined as a microservice so that it is easy to be run and deployed in any use case and infrastructure. In addition, it is fully configurable and adaptable for scenario Moreover, it can be run just to obtain a prediction, or it can be configured to deploy a REST API to access the predictions at any time.
With the data produced by the sensors every day, a database is collected for every entity/id so that a predictive model can be produced for each entity. This model will recognize and detect the patterns in the data so that it is able to forecast (predict), considering some context input data, the next value(s) of the time series; or to estimate the value of a specific target feature. This model is trained by the trainer-estimation, and then stored in Elasticsearch to be deployed in the inference-estimators microservices.
There are several parameters that can be modified to change how the system predicts. These parameters are enclosed in the file ./config/config.ini, and are explained here:
Note: It is very important that these parameters match the ones specified in the configuration file of the trainer used to train the models that are deployed in this estimator.
ESTIMATION section:
timeseries or features and stands for the type of the data (used to train the model). If the datatype is features, the next two parameters are ignored.timeseries.ML section:
The format for time_window parameters follows Date Math from elasticsearch API.
ELASTIC section:
DATA section:
timestampELK section
9200 (default of elasticsearch)MINIO section
DEFAULT section
Use this command to launch the container:
docker run synchronicityiot/estimation-generic:@tag -e MINIO_HOST='@minio_host' -e MINIO_PORT='@minio_port' -e MINIO_ACCESS_KEY='@minio_access' -e MINIO_SECRET_KEY='@minio_secret' -e ELASTIC_HOST='@elastic_host' -e ELASTIC_PORT='@elastic_port' -v ./config/:/usr/src/app/config/config.ini -p 5005:5005
Note that you must specify at least @tag (for example :v1.0) and the folder that contains the configuration file as a volume. You can specify environment variables for the elasticsearch host (@elastic_host) and the elasticsearch port (@elastic_port), if you do not provide them, the ones in the config.ini file will be used. You should also open the port used in the estimator (5005).
In case you might want to include the engine in your docker-compose file, we provide here the code needed to launch it (please configure properly the docker image tag and the elasticsearch environment variables and the MINIO secret and access key):
networks:
ioelab-network:
driver: bridge
volumes:
aimodelsdata:
driver: local
services:
iot-ai-engine:
image: ioelab/estimation-generic:v1.0
container_name: estimation-generic
hostname: estimation-generic_host
volumes:
- ./config/config.ini:/usr/src/app/config/config.ini
environment:
NODE_ENV: development
ELASTIC_HOST: 127.0.0.1
ELASTIC_PORT: 9200
MINIO_HOST: 127.0.0.1
MINIO_PORT: 9200
ESTIMATION_PORT: 5005
MINIO_ACCESS_KEY: {MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: {MINIO_SECRET_KEY}
ports:
- 5005:5005
networks:
ioelab-network:
aliases:
- estimation-generic_host
With the model loaded, predictions can be done either by request (from the REST endpoint or from the execution) or periodically (if you launch the estimator with the scheduler). You can access those predictions in elasticsearch at the index and mapping that you have indicated in the config file. An example of the format of the predictions stored in elasticsearch is:
{
"model_file": "Q7NwDWsB2UYPRYj1IUbr",
"timestamp": "2019-05-31T10:30:30.737034Z",
"algorithm": "lstm",
"id": "urn:ngsi-ld:OnStreetParking:santander:parking:onStreet:StaLuciaEast",
"values": [
17.101938247680664,
16.920570373535156,
16.93316650390625,
16.768169403076172
],
"prediction_times": [
"2019-05-31T10:45:30.737034Z",
"2019-05-31T11:00:30.737034Z",
"2019-05-31T11:15:30.737034Z",
"2019-05-31T11:30:30.737034Z"
],
"latency": "0.45788"
}
If you run the estimator as a REST API, ask for a prediction via a GET method to the estimator with:
curl -X GET http://127.0.0.1:5000/predict/id
Notice that it is necessary to indicate the id of the entity corresponding to the estimations. This will return a JSON object with the format (if id = urn:ngsi-ld:OnStreetParking:santander:parking:onStreet:StaLuciaEast):
{
"timestamp": "2019-05-31T10:30:30.737034Z",
"id": "urn:ngsi-ld:OnStreetParking:santander:parking:onStreet:StaLuciaEast",
"prediction": [
17.101938247680664,
16.920570373535156,
16.93316650390625,
16.768169403076172
],
"prediction_times": [
"2019-05-31T10:45:30.737034Z",
"2019-05-31T11:00:30.737034Z",
"2019-05-31T11:15:30.737034Z",
"2019-05-31T11:30:30.737034Z"
],
"latency": "0.1",
"status": "success"
}
Content type
Image
Digest
Size
497.3 MB
Last updated
over 6 years ago
docker pull synchronicityiot/estimation-generic:2.1