filter_by_threshold

ketos.neural_networks.dev_utils.detection.filter_by_threshold(detections, threshold=0.5, highest_score_only=False)[source]

Filters out detection scores below a specified threshold and returns a DataFrame with the remaining detections.

Args:
detections: dict

The dictionary with the detections.

threshold: float

The threshold below which scores are filtered out. Default is 0.5.

highest_score_only: bool

If True, only the highest score is returned. Default is False.

Returns:

pd.DataFrame: DataFrame with the remaining detections.

Examples:

>>> detections = {
...    'filename': ['file1', 'file2'],
...    'start': [0, 1],
...    'end': [1, 2],
...    'score': [[0.2, 0.7, 0.3], [0.1, 0.4, 0.8]]
... }
>>> filter_by_threshold(detections, 0.5)
  filename  start  end  label  score
0    file1      0    1      1    0.7
1    file2      1    2      2    0.8