conmo.metrics.RMSPE

class conmo.metrics.RMSPE(normalize: bool = True)[source]
__init__(normalize: bool = True) None[source]
calculate(idx: int, algorithms: Iterable[str], last_preprocess_dir: str, algorithms_dir: str, metrics_dir: str) None[source]

Calculates specific metric for each of the algorithms’ results.

Parameters
  • idx (str) – Index of the metric in the Experiment. Userful in case you want to calculate several metrics.

  • algoritmss (Iterable[str]) – List of names of the selected algorithms.

  • last_preprocess_dir – Name of the directory where the ground truth is located

  • algorithms_dir – Name of the directory where the results of the algorithms executions are stored.

  • metrics_dir – Name of th edirectory where the results will be stored.

labels_per_sequence(labels: DataFrame) bool

Use only with time series datasets. Checks if the labels file of the chosen dataset has an index format with sequences only or sequences and time. This method in future updates will be changed to a specific class for time series.

Parameters

labels (Pandas Dataframe) – Labels file of the dataset.

Returns

True if the labels contains 1 level of index with sequence or False if the labels file contains 2 leves with sequence and time.

Return type

bool

Raises

RuntimeError – If the number of index levels is invalid.

load_results(algorithm: str, algorithms_dir: str) DataFrame

Load results for a specific algorthm.

Parameters
  • algoritm (str) – Name of the selected algorithm.

  • algorithms_dir (str) – Name of the directory where the results of the algorithms executions are stored.

Returns

Dataframe cantainig the results (predictions).

Return type

Pandas Dataframe

load_truth(last_preprocess_dir: str)

Load labels from the last preprocess directory.

Parameters

last_preprocess_dir (str) – Last diretory where the labels dataframe was stored.

Returns

Dataframe cantainig the labels.

Return type

Pandas Dataframe

problem_label(truth: DataFrame) str

Determinates the nature of the problem by identifying the column’s name of the labels.

Parameters

truth (Pandas Dataframe) – Labels file of the dataset.

Returns

Returns the column for the metric.

Return type

str

Raises

RuntimeError – If the labels of the ground truth are invalid for the problem.

rmspe(y_true: ndarray, y_pred: ndarray) ndarray[source]

Compute Root Mean Square Percentage Error between two arrays.

save_output(metric: DataFrame, idx: int, metrics_dir: str) None

Save metric’s output to disk.

Parameters
  • metric (Pandas Dataframe) – Dataframe containing the metric’s results.

  • idx (int) – Index of the metric in the Experiment. Userful in case you want to calculate several metrics.

  • metrics_dir (str) – Name of the directory where the results will be stored.

show_start_message()

Simple method to print on the terminal the name of the used metric.

Methods

__init__([normalize])

calculate(idx, algorithms, ...)

Calculates specific metric for each of the algorithms' results.

labels_per_sequence(labels)

Use only with time series datasets.

load_results(algorithm, algorithms_dir)

Load results for a specific algorthm.

load_truth(last_preprocess_dir)

Load labels from the last preprocess directory.

problem_label(truth)

Determinates the nature of the problem by identifying the column's name of the labels.

rmspe(y_true, y_pred)

Compute Root Mean Square Percentage Error between two arrays.

save_output(metric, idx, metrics_dir)

Save metric's output to disk.

show_start_message()

Simple method to print on the terminal the name of the used metric.