Skip to content

Abstract Base Classes

Metric

The abstract base class for metrics.

Properties should be implemented as class attributes in derived metrics

The compute_metric method needs to be implemented

Attributes

full_name abstractmethod instance-attribute property

A human-readable name for this metric.

is_multiclass abstractmethod instance-attribute property

Whether or not this metric computes a value for each class individually, or for all classes at once.

bounds abstractmethod instance-attribute property

A tuple of the minimum and maximum possible value for this metric to take.

Can be infinite.

dependencies abstractmethod instance-attribute property

All metrics upon which this metric depends.

Used to generate a computation schedule, such that no metric is calculated before its dependencies. The dependencies must match the compute_metric signature. This is checked during class definition.

sklearn_equivalent abstractmethod instance-attribute property

The sklearn equivalent function, if applicable.

aliases abstractmethod instance-attribute property

A list of all valid aliases for this metric.

Can be used when creating metric syntax strings.

name property

The name of this metric.

Will try to use the name used by the user.

Otherwise, takes the first element in the aliases list.

Functions

compute_metric abstractmethod

Computes the metric values from its dependencies.

__call__

Computes the metric values from its dependencies.

AveragedMetric

The composition of any instance of Metric with any instance of Averaging.

Parameters:

  • metric (Metric) –

    a binary metric

  • averaging (Averaging) –

    an averaging method

Attributes

aliases property

A list of all valid aliases for this metric.

Constructed from the product of the all aliases of the Metric and Averaging methods.

Can be used when creating metric syntax strings.

full_name property

The full, human-readable name for this composed metric.

is_multiclass property

Whether this metric computes a value for each class, or for all classes at once.

An AveragedMetric is always multiclass.

bounds property

A tuple of the minimum and maximum possible value for this metric to take.

Can be non-finite.

dependencies property

All metrics upon which this AveragedMetric depends.

Constructed from the union of all Metric and AveragingMethod dependencies.

Used to generate a computation schedule.

The dependencies must match the compute_metric signature.

This is checked during class definition.

sklearn_equivalent property

The sklearn equivalent function, if applicable.

name property

The name of this composed metric.

Combines the names of the base metric and averaging method instances.

Functions

compute_metric

Computes the metric values from its dependencies.

compute_average

Computes the average across experiment classes.

__call__

Computes the metric and averages it, in succession.