# dm.models package

## Subpackages

- dm.models.estimate package
  - Submodules
  - dm.models.estimate.Estimate module
  - Module contents
- dm.models.open_detector package
  - Submodules
  - dm.models.open_detector.adapted_models module
  - dm.models.open_detector.create_attrs module
  - dm.models.open_detector.generic_training_file module
  - dm.models.open_detector.generic_training_file_from_local_db module
  - Module contents
- dm.models.predictor package
  - Submodules
  - dm.models.predictor.THPredictorUtil module
  - dm.models.predictor.generic_training_file module
  - dm.models.predictor.generic_training_file_from_local_db module
  - Module contents

## Submodules

## dm.models.ModelsUtil module

class `dm.models.ModelsUtil.``ModelsUtil`

  Bases: `object`

  static `anomaly_diff`(devs, cls, lat, lon, actual_time, weather, min_diff, diff_time, a_type)

    It detect an anomaly within given time interval.

    Parameters

      - devs – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - weather – class that obtains information about weather

      - min_diff – minimal difference between measured values

      - diff_time – window size for anomaly detection

      - a_type – type of anomaly detection (temperature, humidity or co2)

    Returns

      notification that contains information about anomaly

  static `dew_point`(devs, cls, lat, lon, actual_time, weather)

    It calculates dew point.

    Parameters

      - devs – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - weather – class that obtains information about weather

    Returns

      notification that contains information about dew point

  static `estimate_co2`(device, cls, actual_time)

    It estimates values in given time on the basis of CO2 concentration.

    Parameters

      - device – information about device

      - cls – list of clients

      - actual_time – current timestamp

    Returns

      notification that contains information about estimation

  static `estimate_open_co2`(device, cls, lat, lon, actual_time, weather)

    It estimates if window was open on the basis of CO2 concentration.

    Parameters

      - device – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - weather – class that obtains information about weather

    Returns

      notification that contains information about estimation

  static `estimate_open_t_h`(device, cls, lat, lon, actual_time, weather)

    It estimates if window was open on the basis of temperature and humidity.

    Parameters

      - device – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - weather – class that obtains information about weather

    Returns

      notification that contains information about estimation

  static `estimate_t_h`(device, cls, actual_time)

    It estimates values in given time on the basis of humidity.

    Parameters

      - device – information about device

      - cls – list of clients

      - actual_time – current timestamp

    Returns

      notification that contains information about estimation

  static `json_to_file`(json_data, filename, log_notification)

    It saves JSON structure into the file.

    Parameters

      - json_data – JSON structure containing data

      - filename – name of output file

      - log_notification – true if notification is logged

    Returns

      None

  static `load_model`(type, device)

    It loads model for window opening detector from file.

    Parameters

      - type – type of model, t_h or co2

      - device – information about device

    Returns

      loaded model

  static `load_model_predictor`(type, device)

    It loads model for predictor from file.

    Parameters

      - type – type of model, t_h or co2

      - device – information about device

    Returns

      loaded model

  static `predictor`(device, cls, lat, lon, actual_time, module_type, weather, decrease=None)

    It predicts length of ventilation to decrease quantity to required level.

    Parameters

      - device – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - module_type – type of module, t_h or CO2

      - weather – class that obtains information about weather

      - decrease – value that defines how much quantity value should be decreased

    Returns

      notification that contains information about estimation

  static `read_generic_data`(model_type)

    It gets list of attributes from file.

    The attributes are used in model for window opening detector.

    Parameters

      model_type – type of model, t_h or co2

    Returns

      list of attributes

  static `replace_co2_ventilation_len`(data)

    It moves value of CO2 concentration after regression to event attribute.

    Parameters

      data – list of data

    Returns

      modified list of data

  static `replace_nothing_open`(data)

    It converts value of event attribute to boolean.

    Attribute value open is represented by 1 and close by 0.

    Parameters

      data – list of data

    Returns

      modified list of data

  static `replace_ventilation_length`(data)

    It removes quotation marks in value of ventilation length attribute.

    Parameters

      data – list of data

    Returns

      modified list of data

  static `when_ventilate_summer`(devs, cls, lat, lon, actual_time, weather, temperature_diff)

    It determines if ventilation should be performed on the basis of temperature difference.

    Parameters

      - devs – information about device

      - cls – list of clients

      - lat – latitude of locality

      - lon – longitude of locality

      - actual_time – current timestamp

      - weather – class that obtains information about weather

      - temperature_diff – difference between inside and outside temperature

    Returns

      notification that contains information about estimation

  static `write_model`(attrs, filename, replace, event_column='event')

    It saves model to the output file.

    Parameters

      - attrs – list of attributes

      - filename – name of output file

      - replace – function that replaces an attribute

      - event_column – name of attribute that denotes class

    Returns

      None

## Module contents