BaseMetric#
- class empulse.metrics.BaseMetric[source]#
Abstract interface shared by every metric usable as a cost-sensitive
loss.MetricandMixtureMetricboth implement this interface. Cost-sensitive models (e.g.CSLogitClassifier,CSBoostClassifier,CSThresholdClassifier) accept anyBaseMetricas theirlossparameter, rather than being hard-coded to the concreteMetricclass. This is what allowsMixtureMetric– or any future composite/custom metric type – to be used as a drop-in replacement forMetricwherever a metric-based loss is expected, without every model having to special-case each concrete metric type.Subclassing
BaseMetricdirectly is only necessary when implementing a new kind of metric from scratch. To combine existingMetricobjects, useMixtureMetricinstead.- 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.