fl4health.metrics.metric_managers module

class MetricManager(metrics, metric_manager_name)[source]

Bases: object

__init__(metrics, metric_manager_name)[source]

Class to manage a set of metrics associated to a given prediction type.

Parameters:
  • metrics (Sequence[Metric]) – List of metric to evaluate predictions on.

  • metric_manager_name (str) – Name of the metric manager (ie train, val, test)

check_target_prediction_keys_equal(preds, target)[source]
Return type:

None

clear()[source]

Clears data accumulated in each metric for each of the prediction type.

Return type:

None

compute()[source]

Computes set of metrics for each prediction type.

Returns:

dictionary containing computed metrics along with string identifiers for each prediction type.

Return type:

Metrics

reset()[source]

Resets the metrics to their initial state.

Return type:

None

update(preds, target)[source]

Updates (or creates then updates) a list of metrics for each prediction type.

Parameters:
  • preds (TorchPredType) – A dictionary of preds from the model

  • target (TorchTargetType) – The ground truth labels for the data. If target is a dictionary with more than one item, then each value in the preds dictionary is evaluated with the value that has the same key in the target dictionary. If target has only one item or is a torch.Tensor, then the same target is used for all predictions.

Return type:

None