emloop_tensorflow.metrics

Module with TF util functions computing various ml metrics.

Functions

  • bin_stats(): Calculate f1, precision and recall from binary classification expected and predicted values.
  • bin_dice(): Calculate Sorensen–Dice coefficient from the given binary classification expected and predicted values.
emloop_tensorflow.metrics.bin_stats(predictions, labels, prefix=None, suffix=None)[source]

Calculate f1, precision and recall from binary classification expected and predicted values.

Parameters:
  • predictions (Tensor) – 2-d tensor (batch, predictions) of predicted 0/1 classes
  • labels (Tensor) – 2-d tensor (batch, labels) of expected 0/1 classes
  • prefix (Optional[str]) – prefix of the output tensor names
  • suffix (Optional[str]) – suffix of the output tensor names
Return type:

Tuple[Tensor, Tensor, Tensor]

Returns:

a tuple of batched (f1, precision and recall) values

emloop_tensorflow.metrics.bin_dice(predictions, labels)[source]

Calculate Sorensen–Dice coefficient from the given binary classification expected and predicted values.

The coefficient is defined as \(2*|X \cup Y| / (|X| + |Y|)\).

Parameters:
  • predictions (Tensor) – 2-d tensor (batch, predictions) of predicted 0/1 classes
  • labels (Tensor) – 2-d tensor (batch, labels) of expected 0/1 classes
Return type:

Tensor

Returns:

batched Sørensen–Dice coefficients