MetricResults

class MetricResults(data)[source]

Bases: Generic[MetricKeyType]

Results from computing metrics.

Initialize the result wrapper.

Methods Summary

get_metric(name)

Get the given metric from the results.

key_from_string(s)

Parse the metric key from a (un-normalized) string.

key_to_string(s)

Convert a key to a normalized key.

string_or_key_to_key(s)

Convert a key to a named tuple.

to_df()

Output the metrics as a pandas dataframe.

to_dict()

Extract a (potentially nested) JSON-compatible dictionary.

to_flat_dict()

Get the results as a flattened dictionary.

Methods Documentation

Parameters:

data (Mapping[MetricKeyType, float]) –

get_metric(name)[source]

Get the given metric from the results.

Parameters:

name (Union[str, ~MetricKeyType]) – The name of the metric

Return type:

float

Returns:

The value for the metric

abstract classmethod key_from_string(s)[source]

Parse the metric key from a (un-normalized) string.

Parameters:

s (UnionType[str, None]) – the metric key, or None to get the default key.

Return type:

~MetricKeyType

Returns:

the fully resolved key as a named tuple

classmethod key_to_string(s)[source]

Convert a key to a normalized key.

Return type:

str

Parameters:

s (str | MetricKeyType | None) –

classmethod string_or_key_to_key(s)[source]

Convert a key to a named tuple.

Return type:

~MetricKeyType

Parameters:

s (str | MetricKeyType | None) –

to_df()[source]

Output the metrics as a pandas dataframe.

Return type:

DataFrame

to_dict()[source]

Extract a (potentially nested) JSON-compatible dictionary.

Return type:

Mapping[str, Any]

to_flat_dict()[source]

Get the results as a flattened dictionary.

Return type:

Mapping[str, Any]