nicetoolbox.evaluation.metrics.categorical.F1Score

class nicetoolbox.evaluation.metrics.categorical.F1Score[source]

Bases: _BinaryClassificationMetric

Calculate the F1 score for binary classification.

Returns:

Dictionary with key (component, algorithm, person, camera, “f1_score”) and the corresponding aggregated F1 score value.

Return type:

Dict[Tuple[str, str, str, str, str], MetricReturnType]

Initializes the metric. Subclasses can use kwargs for specific setup.

Methods

compute

Compute the final metric from the stored state and return as a dictionary.

get_axis3

Get the metrics output description.

reset

Reset the metric's internal state: counts of TP, TN, FP, FN.

update

Update metric state with a batch of data and its corresponding metadata, accumulating counts of true positives, true negatives, false positives, and false negatives.

compute() Dict[Tuple[str, str, str, str, str], List[BatchResult] | AggregatedResult][source]

Compute the final metric from the stored state and return as a dictionary.

get_axis3()

Get the metrics output description. E.g. bone names or joint names.

reset() None

Reset the metric’s internal state: counts of TP, TN, FP, FN.

update(preds: torch.Tensor, gts: torch.Tensor, meta_chunk: ChunkWorkItem, meta_frames: List[FrameInfo]) None

Update metric state with a batch of data and its corresponding metadata, accumulating counts of true positives, true negatives, false positives, and false negatives. Assumes binary classification with predictions and ground truths as boolean tensors.

Parameters:
  • preds (torch.Tensor) – Predictions tensor (binary).

  • gts (torch.Tensor) – Ground truth tensor (binary).

  • meta_chunk (ChunkWorkItem) – Metadata for the chunk.

  • meta_frames (List[FrameInfo]) – List of frame metadata.