compute_matches#
- DetectionEvaluator.compute_matches(predictions_names: str | Iterable[str] | None = None, min_iou: float = 0, category_agnostic: bool = False) dict[str, DataFrame][source]#
Get matches between predictions and targets of the Evaluator.
See also
- Parameters:
predictions_names – name or collection of prediction names to compute the matches on. If set to None, will compute the matches with the prediction DataFrames contained in the
self.predictions_dictionaryattribute. Defaults to Nonemin_iou – IoU above which the detection is considered valid. Defaults to 0. Note that the lower bound of min_iou is not inclusive.
category_agnostic – if set to False, matches are computed between categories, otherwise, matches are computed globally
- Returns:
dict of DataFrame of matches, one entry per prediction specified in arguments. Will contain
prediction_idandgroundtruth_idcolumns. Index is unrelevant. Each prediction id and target id should appear once and only once. As such, at worse (no match at all), the dataframe will be \(N+M\) rows with \(N\) the number of predictions and \(M\) the number of targets, and at best it will be \(max(M,N)\)
Example
>>> from lours.utils.doc_utils import dummy_dataset >>> groundtruth = dummy_dataset( ... 10, ... 1000, ... label_map={0: "person", 1: "car"}, ... ) >>> predictions1 = dummy_dataset( ... 10, ... 10000, ... label_map=groundtruth.label_map, ... images=groundtruth.images, ... add_confidence=True, ... seed=0, ... ) >>> predictions2 = dummy_dataset( ... 10, ... 10000, ... label_map=groundtruth.label_map, ... images=groundtruth.images, ... add_confidence=True, ... seed=1, ... ) >>> evaluator = DetectionEvaluator( ... groundtruth=groundtruth, A=predictions1, B=predictions2 ... ) >>> matches = evaluator.compute_matches() computing matches between groundtruth and A (category specific) computing matches between groundtruth and B (category specific) >>> matches["A"] prediction_id iou groundtruth_id 0 2311 0.370857 207 1 515 0.586261 820 2 7071 0.468022 585 3 4444 0.089832 87 4 235 0.431787 105 .. ... ... ... 487 5016 0.000000 <NA> 488 3608 0.000000 <NA> 489 437 0.000000 <NA> 490 8837 0.000000 <NA> 491 2508 0.000000 <NA> [10000 rows x 3 columns]
You can select a particular set of prediction to only compute them
>>> B_matches = evaluator.compute_matches( ... predictions_names="B", category_agnostic=True ... ) computing matches between groundtruth and B (category agnostic) >>> B_matches["B"] prediction_id iou groundtruth_id 0 7849 0.267152 832 1 8819 0.089308 130 2 6537 0.322729 785 3 1616 0.406822 326 4 8021 0.510778 929 ... ... ... ... 1022 7377 0.000000 <NA> 1023 8370 0.000000 <NA> 1024 3534 0.000000 <NA> 1025 7087 0.000000 <NA> 1026 1410 0.000000 <NA> [10000 rows x 3 columns]