reporting
birdnet_stm32.evaluation.reporting
¶
ASCII visualization, CSV/JSON export, and optional HTML report for evaluation results.
print_ascii_histogram(scores, bins=10, width=40)
¶
Print an ASCII histogram of scores in [0,1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
ndarray
|
Array of scores in [0, 1]. |
required |
bins
|
int
|
Number of histogram bins. |
10
|
width
|
int
|
Bar width in characters. |
40
|
Source code in birdnet_stm32/evaluation/reporting.py
print_ascii_pr_curve(y_true, y_scores, bins=10, width=40)
¶
Print an ASCII PR curve with fixed precision bins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
ndarray
|
One-hot ground-truth labels [N_files, C]. |
required |
y_scores
|
ndarray
|
Pooled scores [N_files, C]. |
required |
bins
|
int
|
Number of precision bins. |
10
|
width
|
int
|
Bar width in characters. |
40
|
Source code in birdnet_stm32/evaluation/reporting.py
save_predictions_csv(per_file, classes, out_path)
¶
Save per-file predictions to CSV.
Columns: file, label, top1_label, top1_score,
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_file
|
list[dict]
|
One dict per file with keys: file, label, scores. |
required |
classes
|
list[str]
|
Ordered class names. |
required |
out_path
|
str
|
Path to save the CSV. |
required |
Source code in birdnet_stm32/evaluation/reporting.py
print_confusion_matrix(y_true, y_scores, classes, threshold=0.5)
¶
Print an ASCII confusion matrix based on top-1 predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
ndarray
|
One-hot ground-truth labels [N, C]. |
required |
y_scores
|
ndarray
|
Predicted scores [N, C]. |
required |
classes
|
list[str]
|
Ordered class names. |
required |
threshold
|
float
|
Minimum score to count as a prediction (else "none"). |
0.5
|
Source code in birdnet_stm32/evaluation/reporting.py
save_confusion_matrix_plot(y_true, y_scores, classes, out_path, threshold=0.5)
¶
Save a matplotlib confusion matrix heatmap to a file.
Requires matplotlib. Silently skips if not available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
ndarray
|
One-hot ground-truth labels [N, C]. |
required |
y_scores
|
ndarray
|
Predicted scores [N, C]. |
required |
classes
|
list[str]
|
Ordered class names. |
required |
out_path
|
str
|
Path to save the image (e.g., .png). |
required |
threshold
|
float
|
Minimum score to count as a prediction. |
0.5
|
Source code in birdnet_stm32/evaluation/reporting.py
save_species_report_csv(species_data, out_path)
¶
Save per-species AP with confidence intervals to CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
species_data
|
list[dict]
|
Output of |
required |
out_path
|
str
|
Output CSV path. |
required |
Source code in birdnet_stm32/evaluation/reporting.py
save_benchmark_json(metrics, classes, model_path, out_path, species_data=None, config=None)
¶
Save a structured JSON benchmark report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
dict
|
Metrics dict from |
required |
classes
|
list[str]
|
Ordered class names. |
required |
model_path
|
str
|
Path to the evaluated model. |
required |
out_path
|
str
|
Output JSON path. |
required |
species_data
|
list[dict] | None
|
Optional per-species AP with CIs from |
None
|
config
|
dict | None
|
Optional model config dict. |
None
|
Source code in birdnet_stm32/evaluation/reporting.py
print_ascii_det_curve(far, frr, bins=10, width=40)
¶
Print an ASCII DET curve (FAR vs FRR).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
far
|
ndarray
|
False acceptance rate array. |
required |
frr
|
ndarray
|
False rejection rate array. |
required |
bins
|
int
|
Number of FRR bins. |
10
|
width
|
int
|
Bar width in characters. |
40
|
Source code in birdnet_stm32/evaluation/reporting.py
save_det_curve_plot(far, frr, out_path)
¶
Save a matplotlib DET curve plot.
Requires matplotlib. Silently skips if not available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
far
|
ndarray
|
False acceptance rate array. |
required |
frr
|
ndarray
|
False rejection rate array. |
required |
out_path
|
str
|
Output image path. |
required |
Source code in birdnet_stm32/evaluation/reporting.py
save_html_report(metrics, classes, y_true, y_scores, model_path, out_path, species_data=None, per_file=None)
¶
Generate a self-contained HTML evaluation report.
Uses inline CSS and basic HTML tables — no external dependencies. Optionally embeds matplotlib charts as base64 PNG if matplotlib is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
dict
|
Metrics dict from |
required |
classes
|
list[str]
|
Ordered class names. |
required |
y_true
|
ndarray
|
Ground-truth labels |
required |
y_scores
|
ndarray
|
Predicted scores |
required |
model_path
|
str
|
Path to the evaluated model. |
required |
out_path
|
str
|
Output HTML path. |
required |
species_data
|
list[dict] | None
|
Optional per-species AP with CIs. |
None
|
per_file
|
list[dict] | None
|
Optional per-file predictions. |
None
|
Source code in birdnet_stm32/evaluation/reporting.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |