traveltimes_prediction.interface package

Submodules

traveltimes_prediction.interface.prediction_manager module

class traveltimes_prediction.interface.prediction_manager.PredictionManager[source]

Bases: object

Class managing the prediction routine for all allowed sections.

launch_prediction(sections=['TEST-TEST'], prediction_interval_s=60, test_dtime=None)[source]

Method for looped prediction of traveltime.

Parameters:
  • sections (list) – list of all sections for which the prediction should be executed.
  • prediction_interval_s (number) – how often should the manager execute prediction.
  • test_dtime (datetime) – For TESTING PURPOSES – artificial “now” datetime.

traveltimes_prediction.interface.section_interface module

class traveltimes_prediction.interface.section_interface.SectionInterface(section, models)[source]

Bases: object

Class - interface of the individual sections. Serves to train models for sections and predict using these models.

predict(time_interval, db_interface)[source]

Method for prediction of the traveltime, taking data from given time_interval.

Parameters:
  • time_interval (dict) – {‘from’: datetime, ‘to’: datetime}
  • db_interface (object) – instance of DBInterface
Returns:

list of dict - info about the process of prediction

traveltimes_prediction.interface.training_manager module

class traveltimes_prediction.interface.training_manager.TrainingManager[source]

Bases: object

Class for training of the models for specified sections.

prepare_training_data(section, time_interval_list)[source]

Method for retrieving the data from database and preparing them for training.

Parameters:
  • section (string) – e.g. ‘KOCE-LNCE’
  • time_interval_list (list) – list of dicts - {‘from: datetime, ‘to’: datetime}
Returns:

tuple - (X, Y) - data for training

train(section, MODEL, model_params, X_Y_data)[source]

Method for training of the model.

Parameters:
  • section (string) – e.g. ‘LNCE-KOCE’
  • MODEL (class) – class of the model to be created - e.g. ClusterModel, TimeDomainModel...
  • model_params (dict) – model parameters
  • X_Y_data (tuple) – tuple of DataFrames - input data for training
training_loop(sections=['TEST-TEST'], training_interval_s=86400, train_for=None)[source]

Method for the training to be kept in loop, calls self.train().

Parameters:
  • sections (list) – list of section whose models are gonna be trained.
  • training_interval_s (int) – hours, how often should be the models trained.
  • train_for (datetime.datetime) – for TEST purposes, datetime for which should be trained.

Module contents