frarch.modules.metrics.wrapper module#

class frarch.modules.metrics.wrapper.MetricsWrapper(**kwargs: frarch.modules.metrics.base.Metric)[source]#

Bases: object

Store a set of metrics and perform operations in all of them simultaneously.

Example

Sample code for metrics wrapper:
metrics_wrapper = MetricsWrapper(

metric_str0=Metric0(), metric_str1=Metric1(),

) model = Model()

for batch, labels in dataset:

predictions = model(batch) metrics_wrapper.update(predictions, labels)

print(metrics_wrapper.get_metrics()) # prints {“metric_str0”: 0.0, “metric_str1”: 1.0}

__init__(**kwargs: frarch.modules.metrics.base.Metric) None[source]#

Initialize metrics in wrapper.

Raises

ValueError – if any of the values in kwargs don’t inherit from metric.

get_metrics(*args: Any, **kwargs: Any) Dict[str, frarch.modules.metrics.base.Metric][source]#

Build a dict with aggregated metrics.

Returns

dict with metric names as keys and aggregated metrics as values.

Return type

Dict[str, Metric]

reset() None[source]#

Call reset in all metrics in the MetricsWrapper class.

update(*args: Any, **kwargs: Any) None[source]#

Call update on all metrics in MetricsWrapper class.