Metrics¶
- class utils.metrics.Metrics(y_true: ndarray, y_pred: ndarray, classes: None | ndarray = None)¶
Bases:
object- __init__(y_true: ndarray, y_pred: ndarray, classes: None | ndarray = None)¶
A collection of metrics that evaluate the results of classification.
- Parameters:
y_true (np.ndarray) – The actual class vector/matrix (assuming one-hot encoding in the latter case).
y_pred (np.ndarray) – The predicted class vector/matrix (assuming one-hot encoding in the latter case).
classes (None | np.ndarray) – Vector of unique class values. Required for single output classification accuracy calculation.
- Variables:
_metric_modes – Map for defining which metric is suitable for a certain target type.
- Returns:
None
- Return type:
None
- accuracy_oh() float¶
Accuracy with one-hot encoded target. :return: Classification accuracy :rtype: float
- accuracy_reg() float¶
Accuracy of classification calculated from single output (regression). :return: Classification accuracy :rtype: float
- calculate(metrics: list[Callable[[], float]] | str = 'all') dict[str, float]¶
Calculate the given metrics based on the target labels. The functions are called based on the class vector shape.
- Parameters:
metrics – List of functions to call. Alternatively, “all” to calculate all metrics. Default value is “all”.
- Returns:
Dictionary with metric names as keys and scores as values.
- Return type:
dict[str, float]
- root_mean_squared() float¶
Root-Mean Squared error. :return: RMS error :rtype: float
- root_mean_squared_oh() float¶
Root-Mean Squared error with one-hot encoded target. :return: RMS error :rtype: float
- scaled_root_mean_squared() float¶
Scaled Root-Mean Squared error. Used with target vectors scaled between 0.1 and 0.9. :return: SRMS error :rtype: float
- scaled_root_mean_squared_oh() float¶
Scaled Root-Mean Squared error with one-hot encoded target. Used with target vectors scaled between 0.1 and 0.9. :return: SRMS error :rtype: float