dacapo.experiments.tasks.evaluators.instance_evaluator

Attributes

logger

Classes

InstanceEvaluator

A class representing an evaluator for instance segmentation tasks.

Functions

relabel(array[, return_backwards_map, inplace])

Relabel array, such that IDs are consecutive. Excludes 0.

voi(truth, test)

Calculate the variation of information (VOI) between two segmentations.

Module Contents

dacapo.experiments.tasks.evaluators.instance_evaluator.logger
dacapo.experiments.tasks.evaluators.instance_evaluator.relabel(array, return_backwards_map=False, inplace=False)

Relabel array, such that IDs are consecutive. Excludes 0.

Parameters:
  • array (ndarray) – The array to relabel.

  • return_backwards_map (bool, optional) – If True, return an ndarray that maps new labels (indices in the array) to old labels.

  • inplace (bool, optional) – Perform the replacement in-place on array.

Returns:

A tuple (relabelled, n), where relabelled is the relabelled array and n the number of unique labels found. If return_backwards_map is True, returns (relabelled, n, backwards_map).

Raises:

ValueError – If array is not of type np.ndarray.

Examples

>>> array = np.array([[1, 2, 0], [0, 2, 1]])
>>> relabel(array)
(array([[1, 2, 0], [0, 2, 1]]), 2)
>>> relabel(array, return_backwards_map=True)
(array([[1, 2, 0], [0, 2, 1]]), 2, [0, 1, 2])

Note

This function is used to relabel an array, such that IDs are consecutive. Excludes 0.

class dacapo.experiments.tasks.evaluators.instance_evaluator.InstanceEvaluator

A class representing an evaluator for instance segmentation tasks.

criteria

List[str] the evaluation criteria

evaluate(output_array_identifier, evaluation_array)

Evaluate the output array against the evaluation array.

score()

Return the evaluation scores.

Note

The InstanceEvaluator class is used to evaluate the performance of an instance segmentation task.

criteria: List[str] = ['voi_merge', 'voi_split', 'voi']

A list of all criteria for which a model might be “best”. i.e. your criteria might be “precision”, “recall”, and “jaccard”. It is unlikely that the best iteration/post processing parameters will be the same for all 3 of these criteria

Returns:

List[str]

the evaluation criteria

Raises:

NotImplementedError – if the function is not implemented

Examples

>>> evaluator = Evaluator()
>>> evaluator.criteria
[]

Note

This function is used to return the evaluation criteria.

evaluate(output_array_identifier, evaluation_array)

Evaluate the output array against the evaluation array.

Parameters:
  • output_array_identifier – str the identifier of the output array

  • evaluation_array – ZarrArray the evaluation array

Returns:

InstanceEvaluationScores

the evaluation scores

Raises:

ValueError – if the output array identifier is not valid

Examples

>>> instance_evaluator = InstanceEvaluator()
>>> output_array_identifier = "output_array"
>>> evaluation_array = ZarrArray.open_from_array_identifier("evaluation_array")
>>> instance_evaluator.evaluate(output_array_identifier, evaluation_array)
InstanceEvaluationScores(voi_merge=0.0, voi_split=0.0)

Note

This function is used to evaluate the output array against the evaluation array.

property score: dacapo.experiments.tasks.evaluators.instance_evaluation_scores.InstanceEvaluationScores

Return the evaluation scores.

Returns:

InstanceEvaluationScores

the evaluation scores

Raises:

NotImplementedError – if the function is not implemented

Examples

>>> instance_evaluator = InstanceEvaluator()
>>> instance_evaluator.score
InstanceEvaluationScores(voi_merge=0.0, voi_split=0.0)

Note

This function is used to return the evaluation scores.

dacapo.experiments.tasks.evaluators.instance_evaluator.voi(truth, test)

Calculate the variation of information (VOI) between two segmentations.

Parameters:
  • truth – ndarray the ground truth segmentation

  • test – ndarray the test segmentation

Returns:

dict

the variation of information (VOI) scores

Raises:

ValueError – if the truth and test arrays are not of type np.ndarray

Examples

>>> truth = np.array([[1, 1, 0], [0, 2, 2]])
>>> test = np.array([[1, 1, 0], [0, 2, 2]])
>>> voi(truth, test)
{'voi_split': 0.0, 'voi_merge': 0.0}

Note

This function is used to calculate the variation of information (VOI) between two segmentations.