Skip to contents

Calculates species-specific confidence thresholds for BirdNET detections based on either a target precision or a predicted probability from a logistic regression model. Returns a tibble with one threshold per species. The precision approach is based on Tseng et al., 2025, while the probability approach is based on Wood and Kahl, 2024.

Usage

birdnet_calc_threshold(
  validated_data,
  full_data = NULL,
  probability = NULL,
  precision = NULL
)

Arguments

validated_data

A data frame of validated BirdNET detections with columns common_name, confidence, and validation. The validation column must contain 1 (true positives) and 0 (false positives).

full_data

Optional. A data frame of all BirdNET detections. Must contain at least common_name and confidence columns. If NULL, validated_data will be used.

probability

Target predicted probability (between 0 and 1) used to calculate the threshold from the logistic regression.

precision

Target precision (between 0 and 1) used to select the threshold achieving that precision.

Value

A tibble with two columns:

common_name

Species common name

threshold

Calculated confidence threshold

Details

If precision is provided, thresholds are selected based on the lowest confidence score that achieves or exceeds the desired precision when applied to predicted probabilities. If probability is provided instead, thresholds are calculated directly from the inverse logit of the logistic regression model. You must provide exactly one of precision or probability.

All calculated thresholds are clamped to the range between the minimum observed confidence in validated_data and 1.

Examples

if (FALSE) { # \dontrun{
birdnet_calc_threshold(
  validated_data = validated_df,
  full_data = full_df,
  precision = 0.9
)
} # }