pdmlabs.evaluation.vus.affiliation.generics#

Functions

convert_vector_to_events([vector])

Convert a binary vector (indicating 1 for the anomalous instances) to a list of events.

f1_func(p,Β r)

Compute the f1 function :param p: precision numeric value :param r: recall numeric value :return: f1 numeric value

has_point_anomalies(events)

Checking whether events contain point anomalies, i.e. events starting and stopping at the same time.

infer_Trange(events_pred,Β events_gt)

Given the list of events events_pred and events_gt, get the smallest possible Trange corresponding to the start and stop indexes of the whole series.

read_all_as_events()

Load the files contained in the folder data/ and convert to events. The length of the series is kept. The convention for the file name is: dataset_algorithm.gz :return: two dictionaries: - the first containing the list of events for each dataset and algorithm, - the second containing the range of the series for each dataset.

read_gz_data([filename])

Load a file compressed with gz, such that each line of the file is either 0 (representing a normal instance) or 1 (representing) an anomalous instance.

pdmlabs.evaluation.vus.affiliation.generics.convert_vector_to_events(vector=[0, 1, 1, 0, 0, 1, 0])#

Convert a binary vector (indicating 1 for the anomalous instances) to a list of events. The events are considered as durations, i.e. setting 1 at index i corresponds to an anomalous interval [i, i+1).

Parameters:

vector – a list of elements belonging to {0, 1}

Returns:

a list of couples, each couple representing the start and stop of

each event

pdmlabs.evaluation.vus.affiliation.generics.f1_func(p, r)#

Compute the f1 function :param p: precision numeric value :param r: recall numeric value :return: f1 numeric value

pdmlabs.evaluation.vus.affiliation.generics.has_point_anomalies(events)#

Checking whether events contain point anomalies, i.e. events starting and stopping at the same time.

Parameters:

events – a list of couples corresponding to predicted events

Returns:

True is the events have any point anomalies, False otherwise

pdmlabs.evaluation.vus.affiliation.generics.infer_Trange(events_pred, events_gt)#

Given the list of events events_pred and events_gt, get the smallest possible Trange corresponding to the start and stop indexes of the whole series. Trange will not influence the measure of distances, but will impact the measures of probabilities.

Parameters:
  • events_pred – a list of couples corresponding to predicted events

  • events_gt – a list of couples corresponding to ground truth events

Returns:

a couple corresponding to the smallest range containing the events

pdmlabs.evaluation.vus.affiliation.generics.read_all_as_events()#

Load the files contained in the folder data/ and convert to events. The length of the series is kept. The convention for the file name is: dataset_algorithm.gz :return: two dictionaries:

  • the first containing the list of events for each dataset and algorithm,

  • the second containing the range of the series for each dataset

pdmlabs.evaluation.vus.affiliation.generics.read_gz_data(filename='data/machinetemp_groundtruth.gz')#

Load a file compressed with gz, such that each line of the file is either 0 (representing a normal instance) or 1 (representing) an anomalous instance. :param filename: file path to the gz compressed file :return: list of integers with either 0 or 1