paddlets.metrics.base

class Metric(mode: str = 'normal', **kwargs)[source]

Bases: ABC

Abstract base class used to build new Metric.

Parameters
  • mode (str) – Supported metric modes, only normal, prob and anomaly are valid values. Set to normal for non-probability use cases, set to prob for probability use cases, set to anomaly for anomaly dection.

  • kwargs – Keyword parameters of specific metric functions.

abstract metric_fn(y_true: ndarray, y_pred: ndarray) float[source]

Compute metric’s value from ndarray.

Parameters
  • y_true (np.ndarray) – Ground truth (correct) target values.

  • y_pred (np,ndarray) – Estimated target values.

Returns

Computed metric value.

Return type

float

Raises

ValueError.

classmethod get_metrics_by_names(names: List[str]) List[Metric][source]

Get list of metric classes.

Parameters

names (List[str]) – List of metric names.

Returns

List of metric classes.

Return type

List[Metric]