Evaluation¶
Signal quality metrics and artifact generation for compression evaluation.
Metrics¶
compressionkit.evaluation.metrics.PRD
¶
Bases: Metric
Percent RMS difference metric with optional energy normalization.
Source code in compressionkit/evaluation/metrics.py
compressionkit.evaluation.metrics.TruePRD
¶
Bases: PRD
Normalized PRD metric (convenience alias).
Source code in compressionkit/evaluation/metrics.py
compressionkit.evaluation.metrics.compute_signal_metrics(original, reconstructed, *, noise_power=None)
¶
Compute scalar reconstruction metrics on two aligned signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original
|
ndarray
|
Ground-truth signal (any shape; flattened). |
required |
reconstructed
|
ndarray
|
Reconstructed signal (same total size). |
required |
noise_power
|
float | None
|
Optional estimate of the noise contribution to the
ground-truth power, in the same scale as |
None
|
Source code in compressionkit/evaluation/metrics.py
compressionkit.evaluation.metrics.compute_ppg_physiokit_metrics(signal, *, sample_rate, low_hz, high_hz, order, min_peaks)
¶
Compute HR/HRV metrics for one PPG signal using physiokit.
Source code in compressionkit/evaluation/metrics.py
compressionkit.evaluation.metrics.summarize_physiokit_alignment(originals, reconstructions, *, sample_rate, low_hz, high_hz, order, min_peaks)
¶
Compare physiokit HR/HRV metrics between original and reconstructed signals.
Source code in compressionkit/evaluation/metrics.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
Artifacts¶
compressionkit.evaluation.artifacts.save_sample_artifacts(sample_id, original, reconstructed, sampling_rate, run_dir, band_original=None, band_reconstructed=None, physiokit_metrics=None, save_plot=True)
¶
Save per-sample CSV, plot, and compute metrics for one evaluation sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
int
|
Index of the evaluation sample. |
required |
original
|
ndarray
|
Original signal (1D or squeezable). |
required |
reconstructed
|
ndarray
|
Reconstructed signal (1D or squeezable). |
required |
sampling_rate
|
int
|
Signal sampling rate in Hz. |
required |
run_dir
|
Path
|
Directory to write artifacts into. |
required |
band_original
|
ndarray | None
|
Optional band-filtered original for band metrics. |
None
|
band_reconstructed
|
ndarray | None
|
Optional band-filtered reconstruction. |
None
|
physiokit_metrics
|
dict[str, Any] | None
|
Optional physiokit metrics dict for this sample. |
None
|
save_plot
|
bool
|
If False, skip matplotlib plot generation (CSV + metrics are still written). Useful when you want many samples for metrics but only a handful of visual artifacts. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with paths and metric values. The |
dict[str, Any]
|
when |