evaluators package

Submodules

evaluators.evaluator module

class evaluators.evaluator.Evaluator[source]

Bases: ABC

Abstract class for evaluating the model.

abstract print_metrics()[source]

Print the calculated metrics.

evaluators.regression_evaluator module

class evaluators.regression_evaluator.RegressionEvaluator(tolerance=0.0001)[source]

Bases: Evaluator

Evaluator class for regression tasks. Includes methods to calculate the mean squared error (MSE), mean absolute error (MAE), mean relative error (MRE), quantiles of the absolute errors, L2 error, and R-squared.

Parameters:

tolerance (float) – Tolerance level to consider values close to zero for MRE calculation (default: 1e-4).

R2(y_true, y_pred)[source]

Calculate the R-squared (coefficient of determination) for a set of true and predicted values.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

Returns:

The R-squared value.

Return type:

float

ae_q(y_pred, y_true, quantile)[source]

Calculate the quantile of the absolute errors between the true and predicted values.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

  • quantile (int) – The quantile to calculate. Must be between 0 and 100.

Returns:

The quantile of the absolute errors.

Return type:

float

l2_error(y_pred, y_true)[source]

Calculate the L2 error between the true and predicted values.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

Returns:

The L2 error.

Return type:

float

mean_absolute_error(y_true, y_pred)[source]

Compute the mean absolute error (MAE) between the true values and the predicted values.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

Returns:

The mean absolute error.

Return type:

float

mean_relative_error(y_pred, y_true)[source]

Compute the mean relative error (MRE) between the true values and the predicted values, excluding cases where y_true is close to zero within a specified tolerance.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

  • tolerance (float) – Tolerance level to consider values close to zero. Default is 1e-4.

Returns:

The mean relative error excluding cases where y_true is close to zero.

Return type:

float

mean_squared_error(y_true, y_pred)[source]

Compute the mean squared error (MSE) between the true values and the predicted values.

Parameters:
  • y_true (numpy.ndarray) – The true values.

  • y_pred (numpy.ndarray) – The predicted values.

Returns:

The mean squared error.

Return type:

float

print_metrics()[source]

Print the calculated regression metrics.

property tolerance: float

evaluators.regression_evaluator_plotter module

class evaluators.regression_evaluator_plotter.RegressionEvaluatorPlotter(plots_path, plots_name=None, tolerance=0.0001, plotters=[])[source]

Bases: RegressionEvaluator

Evaluator class for regression tasks. Besides returning the evaluation metrics, it also create the plots of the `Plotter`s given.

Parameters:
  • plots_path (str) – The path to save the plot.

  • plots_name (str) – The name of the plot (default: None).

  • tolerance (float) – Tolerance level to consider values close to zero for MRE calculation (default: 1e-4).

  • plotters (list) – List of plotters to be used.

Module contents