BaseMetric#

class empulse.metrics.BaseMetric[source]#

Abstract interface shared by every metric usable as a cost-sensitive loss.

Metric and MixtureMetric both implement this interface. Cost-sensitive models (e.g. CSLogitClassifier, CSBoostClassifier, CSThresholdClassifier) accept any BaseMetric as their loss parameter, rather than being hard-coded to the concrete Metric class. This is what allows MixtureMetric – or any future composite/custom metric type – to be used as a drop-in replacement for Metric wherever a metric-based loss is expected, without every model having to special-case each concrete metric type.

Subclassing BaseMetric directly is only necessary when implementing a new kind of metric from scratch. To combine existing Metric objects, use MixtureMetric instead.

abstractmethod __call__(y_true, y_score, **parameters)[source]#

Compute the metric score or loss.

abstract property direction#

Whether the metric is to be maximized or minimized.

abstractmethod optimal_rate(y_true, y_score, **parameters)[source]#

Compute the optimal predicted positive rate.

abstractmethod optimal_threshold(y_true, y_score, **parameters)[source]#

Compute the optimal classification threshold(s).

abstract property strategy#

The strategy used to compute the metric.

For a composite metric, a representative strategy shared by all of its components.