Sign inSign up

synchronicityiot/trainer-estimation-generic

By synchronicityiot

Updated over 6 years ago

Image
0

387

synchronicityiot/trainer-estimation-generic repository overview

Training the models

The trainer 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.

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.

In order to train the model, an Elasticsearch database is used to obtain the data. Models are also stored in Elasticsearch so that they can be loaded from other microservices.

Configuration

There are several parameters that can be modified to change how the system learns. These parameters are enclosed in the file ./config/config.ini, and are explained here:

INFERENCE section:

  • data_type: can be timeseries or features and stands for the type of the data to train the model. If the datatype is features, the next two parameters are ignored.
  • num_forecasts: Number of values that the system will output when a prediction is requested, when the data_type is timeseries.
  • num_previous_measures: This parameter affects the learning algorithm itself, it stands for the length of the time series, which is the number of previous values considered for the learning.

ML section:

  • algorithm: Name of the algorithm to be used as Neural Network, currently 'lstm' (default), 'phasedlstm' and 'dense' models are available.
  • epoch_internal: Number of times the full training set is passed though the neural network for a specific batch size. Default is 50
  • epoch_external: Number of times the batch_size is increased and the neural network is retrained (epoch_internal times). Default is 1
  • batch_size: Number of examples or size of the batches in which each epoch_internal is divided. Default is 200 (increases with each epoch_external)
  • initial_validation_split: Percentage of validation examples used to test the model when training (for the optimizing function). Default is 0.05
  • validation_split_multiplayer: Multiplier of the validation split used in each epoch_external. Default is 1.75
  • batch_size_multiplier: Multiplier of the size of the batches for every epoch external. Default is 1.5
  • minimum_samples: Minimum number of samples to train the system
  • training_size: Number of samples which will be used to train the model
  • time_window_to: Period of time for looking back for data in elasticsearch. One week is 1w. One month would be 1M
  • time_window_from: Time to start looking back to for data in elasticsearch. Default is now

The format for time_window parameters follows Date Math from elasticsearch API.

ELASTIC section:

  • index_entities: Name of the index that stores the entities
  • index_data: Name of the index that stores the data
  • index_scalers: Name of the index that stores the scalers
  • index_predictions: Name of the index that stores the predictions
  • index_models: Name of the index that stores the models
  • mapping_data: Name of the mapping that defines the format in the index of data
  • mapping_entities: Name of the mapping that defines the format in the index of entities
  • mapping_models: Name of the mapping that defines the format in the index of models
  • mapping_predictions: Name of the mapping that defines the format in the index of predictions

DATA section:

  • time_index: Column label used for indexing data (timestamp column), typically timestamp
  • inference_features: Name of the feature(s) that is/are going to be forecasted
  • dataset_features: Name of the other features used only for training

ELK section

  • elastic_host: Hostname of elasticsearch. Example: localhost
  • elastic_port: Port of communication with elasticsearch. Example: 9200 (default of elasticsearch)

MINIO section

  • minio_host: Hostname of MINIO. Example: minio
  • minio_port: Port of communication with MINIO (default is '9000')

DEFAULT section

  • endpoint: If True open a REST API for asking for training in localhost (True || False)
  • port: Port where the endpoint will listen (default 5006)
  • schedule: Schedule the training (True || False) every day or every X minutes (only one of both when True).
  • schedule_every_day: Schedule the training every day at a certain time (ex: 04:37). Leave blank if you do not want to schedule by day.
  • schedule_every_minutes: Schedule the training every X minutes (ex: 360). Leave blank if you do not want to schedule by minutes.

Instructions

Use this command to launch the container:

docker run synchronicityiot/trainer-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 -p 5006:5006

Note that you must specify at least @tag (for example :v1.0) and the folder that contains the configuration file as a volume (config.ini). 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 trainer (5006 or the port you selected).

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, the elasticsearch environment variables and the port of the trainer environment variable):

networks:
  ioelab-network:
    driver: bridge

volumes:
  aimodelsdata:
    driver: local

services:

  iot-ai-engine:
    image: ioelab/trainer-estimation-generic:v1.0
    container_name: trainer-estimation-generic
    hostname: trainer-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
      TRAINER_PORT: 5006
      MINIO_ACCESS_KEY: {MINIO_ACCESS_KEY}
      MINIO_SECRET_KEY: {MINIO_SECRET_KEY}
    ports:
      - 5006:5006
    networks:
      ioelab-network:
        aliases:
          - trainer-estimation-generic_host

Tag summary

Content type

Image

Digest

Size

693.8 MB

Last updated

over 6 years ago

docker pull synchronicityiot/trainer-estimation-generic:2.1