Utils package

This package includes some usefull fucntions that are used for logging and formatting the artifacts generated by different executions.

log function

deep_nilmtk.utils.log.log_results(experiment, api_res)[source]

This function logs the final results of the testing in the correspanding experiment for each disaggregator

Parameters
  • experiment (dict) -- dict of the experiment in nilmtk format

  • api_res (nilmtk-api result) -- results of the execution as provided by nilmtk

deep_nilmtk.utils.log.save_results(api_results_f1, time, experiment_name, path='../results')[source]

This function persists teh output of the predictions in a pickel file

Parameters
  • api_results_f1 -- Execution results as returned by the NILMtk-API

  • time -- execution time

  • experiment_name (str) -- Name of the experiment

  • path (str, optional) -- Path to the results folder, defaults to '../results'

deep_nilmtk.utils.log.start_logging(filename, params)[source]

Logs the output of the execution in the specified file

Parameters

filename (str) -- The name of the log file

deep_nilmtk.utils.log.stop_logging(f)[source]

Stops logging the output in the file f

Parameters

f (file) -- Logs file

results function

deep_nilmtk.utils.results.filter_prediction(data, w=10, q=50)[source]

Filters the predictions

param data: The input data power data. :type data: np.array :param sequence_length: The length of sequence, defaults to 10 :type sequence_length: int, optional :param p: The percentile. Defaults to 50. :type p: int, optional :return: array of values for correponding percentile :rtype: np.array

setup function

deep_nilmtk.utils.setup.setup(experiment, experiment_name, results_path='./output/results', mlflow_repo='./output/mlruns/')[source]

Runs NILM experiments as defined with a NILMt-API

Parameters
  • experiment (dict) -- Experiment definition

  • experiment_name (str) -- The name of the current experiment

  • results_path (str, optional) -- The path to the resulst folder, defaults to '../results'

  • mlflow_repo (str, optional) -- The path to the Mlflow folder, defaults to '../mlflow'

utils function

class deep_nilmtk.utils.utils.DictLogger(*args, **kwargs)[source]

PyTorch Lightning dict logger.

log_metrics(metrics, step=None)[source]

Logs the training metrics

Parameters
  • metrics (dict) -- the values of the metrics

  • step (int, optional) -- the ID of the current epoch, defaults to None

deep_nilmtk.utils.utils.get_latest_checkpoint(checkpoint_path)[source]

Returns the latest checkpoint for the model

Parameters

checkpoint_path (str) -- The path to the checkpoints folder

Returns

the latest checkpoint saved during training