Skip to content

GAgreement & reliability · evaluate.separation

Source separation metrics (SI-SDR, SDR, SIR, SAR)

How well do separated signals match the true sources, and how much better are they than the mixture?

Scores separated signals (one column per estimated source) against the true sources (one column per reference), clip by clip, after matching each estimate to the reference it fits best (permutation-invariant matching, so the order of the estimate columns doesn't matter). Reports the scale-invariant signal-to-distortion ratio (SI-SDR, centered), its improvement over the mixture (SI-SDRi) when the mixture is given, the BSS Eval SDR, SIR and SAR (distortion, interference and artifacts, as mir_eval computes them) and a plain SNR. Rows are samples in time order; a clip column splits the table into separate recordings. Identical in Python and R.

Verified in Python and R Python and R agree to 10 decimals Also called SI-SDR, scale-invariant SDR, SI-SNR…

A real result

Example “Three sources mixture”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Source separation metrics (SI-SDR, SDR, SIR, SAR)Recorded · Python and R agreeRecorded 2026-11-25 · 32 values compared
R

Mean SI-SDR 8.1 dB over 2 clip(s) and 3 source(s).

Mean SI-SDR (dB)
8.081
Mean SI-SDRi (dB)
11.413
Mean SDR (dB)
9.581
Mean SIR (dB)
10.972
Mean SAR (dB)
15.629
Mean SNR (dB)
8.620

Plots

SI-SDR by source: mixture and separatedHow do categories compare on one value — and across up to three groups?

Mean over clips. The gap between the dots is SI-SDRi, the gain over the unseparated mixture.

View data
True sourceSignalSI-SDR (dB)
s1Mixture0.2224
s1Separated11.103
s2Mixture−5.643
s2Separated6.031
s3Mixture−4.643
s3Separated6.833
s1Mixture1.127
s1Separated11.966
s2Mixture−6.423
s2Separated5.388
s3Mixture−4.630
s3Separated7.167
BSS Eval by sourceHow do categories compare on one value — and across up to three groups?

SDR counts every error; SIR only leakage from the other sources; SAR only artifacts the separation added.

View data
True sourceMetricdB
s1SDR12.628
s1SIR14.130
s1SAR18.132
s2SDR7.940
s2SIR9.386
s2SAR13.894
s3SDR8.236
s3SIR9.613
s3SAR14.344
s1SDR13.368
s1SIR15.032
s1SAR18.475
s2SDR6.653
s2SIR7.731
s2SAR13.910
s3SDR8.662
s3SIR9.939
s3SAR15.019

Assumptions

  • Signals are aligned in time — Rows are read as samples in time order; a delay between a source and its estimate lowers SI-SDR.
  • No silent sources — Every true source varies in every clip.
  • One estimate per source — 3 separated signals for 3 true sources; matching reordered them in 1 of 2 clips.

Scores by clip and source

ClipTrue sourceMatched estimateSI-SDR (dB)SI-SDRi (dB)Mixture SI-SDR (dB)SDR (dB)SIR (dB)SAR (dB)SNR (dB)
as1est111.10310.8810.222412.62814.13018.13211.124
as2est26.03111.674−5.6437.9409.38613.8946.997
as3est36.83311.477−4.6438.2369.61314.3447.580
bs1est311.96610.8401.12713.36815.03218.47511.685
bs2est15.38811.810−6.4236.6537.73113.9106.477
bs3est27.16711.796−4.6308.6629.93915.0197.856
Python

Mean SI-SDR 8.1 dB over 2 clip(s) and 3 source(s).

Mean SI-SDR (dB)
8.081
Mean SI-SDRi (dB)
11.413
Mean SDR (dB)
9.581
Mean SIR (dB)
10.972
Mean SAR (dB)
15.629
Mean SNR (dB)
8.620

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Signals are aligned in time — Rows are read as samples in time order; a delay between a source and its estimate lowers SI-SDR.
  • No silent sources — Every true source varies in every clip.
  • One estimate per source — 3 separated signals for 3 true sources; matching reordered them in 1 of 2 clips.

Scores by clip and source

ClipTrue sourceMatched estimateSI-SDR (dB)SI-SDRi (dB)Mixture SI-SDR (dB)SDR (dB)SIR (dB)SAR (dB)SNR (dB)
as1est111.10310.8810.222412.62814.13018.13211.124
as2est26.03111.674−5.6437.9409.38613.8946.997
as3est36.83311.477−4.6438.2369.61314.3447.580
bs1est311.96610.8401.12713.36815.03218.47511.685
bs2est15.38811.810−6.4236.6537.73113.9106.477
bs3est27.16711.796−4.6308.6629.93915.0197.856

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Three sources mixtureaud1_separation · clip: clip · estimate: est1, est2, est3 · mixture: mix · reference: s1, s2, s3
  • Two sources short filteraud1_separation · clip: clip · estimate: est1, est2 · mixture: mix12 · reference: s1, s2
  • Column order no matchingaud1_separation · clip: clip · estimate: est1, est2, est3 · reference: s1, s2, s3
  • One recordingaud1_separation · estimate: est3, est1 · reference: s3, s1
  • Degenerate constantaud1_separation · clip: clip · estimate: est1, est2, est3 · reference: s1, s2, s3
  • Degenerate all naaud1_separation · clip: clip · estimate: est1, est2, est3 · reference: s1, s2, s3
  • Degenerate infaud1_separation · clip: clip · estimate: est1, est2, est3 · reference: s1, s2, s3
  • Degenerate n1aud1_separation · clip: clip · estimate: est1, est2, est3 · reference: s1, s2, s3

In the guides

Where it sits in the decision guides

  • Generate: quality (human or automated); relevance, safety, bias; task-specific metrics (BLEU, ROUGE, LLM-as-judge) · DS & ML Decision Guide · How to evaluate — common metrics by question type

What you need

True sourcesnumeric · 1–8 columns
One column per true source signal (for example the clean voice and the music), samples in row order.
Separated signalsnumeric · 1–8 columns
One column per separated signal, as many as true sources. Their order doesn't matter: each is matched to the source it fits best.
Mixture (optional)numeric · 0–1 column
Optional: the mixed signal that was separated. Gives SI-SDRi, the gain over doing nothing.
Clip (optional)categorical · 0–1 column · 1–2000 levels
Optional: a column naming the recording each row belongs to. Each clip is scored on its own; without it the whole table is one recording.

Choices you make

statistics

Match estimates to sourcesdefault on

Pair each separated signal with the true source it fits best (permutation-invariant). Off pairs them in column order.

Remove the mean firstdefault on

Center both signals before SI-SDR, as Le Roux et al. (2019) recommend, so a constant offset isn't counted as distortion.

BSS Eval SDR, SIR and SARdefault on

Also split the error into interference and artifacts by projecting on delayed copies of the sources (slower on long clips).

Advanced

BSS Eval filter lengthdefault 512

Delays (samples) allowed in the distortion filter. 512 is the mir_eval standard; it must be shorter than each clip.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Signals are aligned in time

    Each row must hold the same instant in every column; a delay between a source and its estimate lowers SI-SDR (BSS Eval forgives delays shorter than the filter).

  • No silent sources

    A true source that is silent (all values equal) has no SI-SDR; the run stops and names the clip.

  • One estimate per source

    Give as many separated signals as true sources; extra or missing estimates can't be matched.

What it reports

n_clips
Pairing each separated signal with the true source it fits best, since a separator doesn't know which output is which source.
n_sources
Pairing each separated signal with the true source it fits best, since a separator doesn't know which output is which source.
n_samples
Pairing each separated signal with the true source it fits best, since a separator doesn't know which output is which source.
si_sdr_mean
How close a separated signal is to the true source in dB, ignoring its overall volume; higher is better, 0 dB means as much error as signal.
si_sdr_median
How close a separated signal is to the true source in dB, ignoring its overall volume; higher is better, 0 dB means as much error as signal.
si_sdr_min
How close a separated signal is to the true source in dB, ignoring its overall volume; higher is better, 0 dB means as much error as signal.
si_sdri_mean
The separated signal's SI-SDR minus the mixture's: how much the separation helped compared with doing nothing.
mixture_si_sdr_mean
The separated signal's SI-SDR minus the mixture's: how much the separation helped compared with doing nothing.
sdr_mean
Splits a separation's error into leakage from other sources (SIR), added artifacts (SAR) and both together (SDR), in dB.
sir_mean
Splits a separation's error into leakage from other sources (SIR), added artifacts (SAR) and both together (SDR), in dB.
sar_mean
Splits a separation's error into leakage from other sources (SIR), added artifacts (SAR) and both together (SDR), in dB.
snr_mean
10·log10 of the source's energy over the error's energy; unlike SI-SDR it punishes a correct signal that is too loud or too quiet.
n_permuted
Pairing each separated signal with the true source it fits best, since a separator doesn't know which output is which source.
filter_length
Splits a separation's error into leakage from other sources (SIR), added artifacts (SAR) and both together (SDR), in dB.

Per group, level or term: si_sdr[<source>], si_sdri[<source>], sdr[<source>], sir[<source>], sar[<source>], snr[<source>]

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses numpy, pandas, codesplash; R uses nanoparquet, codesplashr.

Default traps between the two languages

  • Both engines run the same twins (codesplash.audio.separation ↔ codesplashr R/audio_separation.R). BSS Eval's FFT Gram matrices and linear solve match mir_eval 0.8.2 (tests/crosscheck/w8aud1_audio.py); permutation matching uses the shared assignment twin (codesplash.evaluate.assign ↔ cs_eval_lsap), so both engines pick the same pairs.
Python

The exact script CodeSplash ran for example “Three sources mixture” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Source separation metrics (SI-SDR, SDR, SIR, SAR)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.separation 1.0.1 · spec 56f2d5c067a8ae81
# Dataset: aud1_separation (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import ml as csml
from codesplash.audio import separation as sep

# %% Data
df = pd.read_parquet("tests/parity/fixtures/aud1_separation.parquet", columns=["s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip"])
n_input = len(df)
df["clip"] = pd.Categorical(df["clip"], categories=sorted(df["clip"].dropna().unique()))
df = df.dropna(subset=["s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip"])  # listwise deletion over the analysis columns
df["clip"] = df["clip"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip"])  # infinite values stop the run (registry/errors.yaml)

# %% Signals: one column per true source and per separated signal, samples in row order
REFS = ["s1", "s2", "s3"]
ESTS = ["est1", "est2", "est3"]
MIX = "mix"
CLIP = "clip"
PERMUTE = True
ZERO_MEAN = True
BSS = True
FLEN = 512
if len(ESTS) != len(REFS):
    cs.cs_error("CS_E_INVALID_OPTION", option="Separated signals", allowed=f"{len(REFS)} columns, one per true source", value=len(ESTS))
clips = [("all rows", df)] if CLIP is None else [(str(k), g) for k, g in df.groupby(CLIP, observed=True, sort=True)]

# %% Scores per clip: permutation-invariant matching on SI-SDR, then SI-SDRi and BSS Eval
rows = []
n_permuted = 0
for name, g in clips:
    R = g[REFS].to_numpy(dtype=np.float64).T
    E = g[ESTS].to_numpy(dtype=np.float64).T
    for i, c in enumerate(REFS):
        s = R[i] - np.mean(R[i]) if ZERO_MEAN else R[i]
        if float(np.dot(s, s)) == 0.0:
            cs.cs_error("CS_E_UNDEFINED", what="SI-SDR", reason=f"the true source {c} is silent in clip {name}")
    m = g[MIX].to_numpy(dtype=np.float64) if MIX is not None else None
    r = sep.evaluate(R, E, m, zero_mean=ZERO_MEAN, bss=BSS, flen=FLEN, permute=PERMUTE)
    if any(int(r["perm"][i]) != i for i in range(len(REFS))):
        n_permuted += 1
    for i, c in enumerate(REFS):
        rows.append({
            "clip": name, "source": c, "estimate": ESTS[int(r["perm"][i])], "samples": int(R.shape[1]),
            "si_sdr": float(r["si_sdr"][i]),
            "si_sdri": float(r["si_sdri"][i]) if m is not None else None,
            "mixture_si_sdr": float(r["mixture_si_sdr"][i]) if m is not None else None,
            "sdr": float(r["sdr"][i]) if BSS else None,
            "sir": float(r["sir"][i]) if BSS else None,
            "sar": float(r["sar"][i]) if BSS else None,
            "snr": float(r["snr"][i]),
        })


def mean_of(key, source=None):
    v = [x[key] for x in rows if x[key] is not None and (source is None or x["source"] == source)]
    return float(np.mean(v)) if v else None


si = np.array([x["si_sdr"] for x in rows])
values = {
    "n_clips": len(clips), "n_sources": len(REFS), "n_samples": len(df),
    "si_sdr_mean": mean_of("si_sdr"), "si_sdr_median": float(np.median(si)), "si_sdr_min": float(np.min(si)),
    "si_sdri_mean": mean_of("si_sdri"), "mixture_si_sdr_mean": mean_of("mixture_si_sdr"),
    "sdr_mean": mean_of("sdr"), "sir_mean": mean_of("sir"), "sar_mean": mean_of("sar"), "snr_mean": mean_of("snr"),
    "n_permuted": n_permuted, "filter_length": FLEN if BSS else None,
}
for c in REFS:
    for key in ("si_sdr", "si_sdri", "sdr", "sir", "sar", "snr"):
        v = mean_of(key, c)
        if v is not None:
            values[f"{key}[{c}]"] = v

# %% Artifact: one row per clip and source
out = csml.out_dir("target/academy-parity/run-8142/evaluate.separation/three_sources_mixture/out-python")
art = pd.DataFrame(rows, columns=["clip", "source", "estimate", "samples", "si_sdr", "si_sdri", "mixture_si_sdr", "sdr", "sir", "sar", "snr"])
for c in ("clip", "source", "estimate"):
    art[c] = art[c].astype("string")
for c in ("si_sdri", "mixture_si_sdr", "sdr", "sir", "sar"):
    art[c] = pd.to_numeric(art[c], errors="coerce").astype("float64")
art.to_parquet(os.path.join(out, "separation.parquet"), index=False)

# %% Result
cols = [{"key": "clip", "label": "Clip"}, {"key": "source", "label": "True source"}, {"key": "estimate", "label": "Matched estimate"},
        {"key": "si_sdr", "label": "SI-SDR (dB)", "type": "number"}]
if MIX is not None:
    cols += [{"key": "si_sdri", "label": "SI-SDRi (dB)", "type": "number"}, {"key": "mixture_si_sdr", "label": "Mixture SI-SDR (dB)", "type": "number"}]
if BSS:
    cols += [{"key": "sdr", "label": "SDR (dB)", "type": "number"}, {"key": "sir", "label": "SIR (dB)", "type": "number"}, {"key": "sar", "label": "SAR (dB)", "type": "number"}]
cols += [{"key": "snr", "label": "SNR (dB)", "type": "number"}]
tables = [{"key": "scores", "title": "Scores by clip and source", "columns": cols, "rows": [{c["key"]: x[c["key"]] for c in cols} for x in rows[:500]]}]
kind, src, val = [], [], []
for x in rows:
    if MIX is not None:
        kind.append("Mixture"); src.append(x["source"]); val.append(x["mixture_si_sdr"])
    kind.append("Separated"); src.append(x["source"]); val.append(x["si_sdr"])
charts = [cs.chart("si_sdr", "cleveland-dot", "SI-SDR by source" + (": mixture and separated" if MIX is not None else ""), {
    "category": cs.col("True source", src, "categorical", REFS),
    "value": cs.col("SI-SDR (dB)", [v if np.isfinite(v) else None for v in val], "numeric"),
    "group": cs.col("Signal", kind, "categorical", ["Mixture", "Separated"] if MIX is not None else ["Separated"]),
}, note="Mean over clips. The gap between the dots is SI-SDRi, the gain over the unseparated mixture." if MIX is not None else "Mean over clips; higher is better.")]
if BSS:
    metric, msrc, mval = [], [], []
    for x in rows:
        for key, label in (("sdr", "SDR"), ("sir", "SIR"), ("sar", "SAR")):
            metric.append(label); msrc.append(x["source"]); mval.append(x[key] if np.isfinite(x[key]) else None)
    charts.append(cs.chart("bss_eval", "cleveland-dot", "BSS Eval by source", {
        "category": cs.col("True source", msrc, "categorical", REFS),
        "value": cs.col("dB", mval, "numeric"),
        "group": cs.col("Metric", metric, "categorical", ["SDR", "SIR", "SAR"]),
    }, note="SDR counts every error; SIR only leakage from the other sources; SAR only artifacts the separation added."))
assumptions = [
    {"key": "aligned", "label": "Signals are aligned in time", "status": "info",
     "detail": "Rows are read as samples in time order; a delay between a source and its estimate lowers SI-SDR."},
    {"key": "silent_reference", "label": "No silent sources", "status": "pass", "detail": "Every true source varies in every clip."},
    {"key": "same_count", "label": "One estimate per source", "status": "pass",
     "detail": f"{len(ESTS)} separated signals for {len(REFS)} true sources" + (f"; matching reordered them in {n_permuted} of {len(clips)} clips." if PERMUTE else ", paired in column order.")},
]
cs.publish({
    "title": "Source separation metrics (SI-SDR, SDR, SIR, SAR)",
    "engine": cs.engine_info("numpy", "pandas"),
    "n": len(df),
    "summary": f"Mean SI-SDR {values['si_sdr_mean']:.1f} dB over {len(clips)} clip(s) and {len(REFS)} source(s).",
    "statistics": [s for s in [
        {"key": "si_sdr_mean", "label": "Mean SI-SDR (dB)", "value": values["si_sdr_mean"]},
        {"key": "si_sdri_mean", "label": "Mean SI-SDRi (dB)", "value": values["si_sdri_mean"]} if MIX is not None else None,
        {"key": "sdr_mean", "label": "Mean SDR (dB)", "value": values["sdr_mean"]} if BSS else None,
        {"key": "sir_mean", "label": "Mean SIR (dB)", "value": values["sir_mean"]} if BSS else None,
        {"key": "sar_mean", "label": "Mean SAR (dB)", "value": values["sar_mean"]} if BSS else None,
        {"key": "snr_mean", "label": "Mean SNR (dB)", "value": values["snr_mean"]},
    ] if s is not None],
    "tables": tables,
    "assumptions": assumptions,
    "charts": charts,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "separation", "path": os.path.join(out, "separation.parquet"), "format": "parquet"}],
})
R

The exact script CodeSplash ran for example “Three sources mixture” · R version 4.5.1 (2025-06-13)

# Source separation metrics (SI-SDR, SDR, SIR, SAR)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.separation 1.0.1 · spec 56f2d5c067a8ae81
# Dataset: aud1_separation (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud1_separation.parquet", col_select = c("s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip")))
n_input <- nrow(df)
df[["clip"]] <- factor(df[["clip"]], levels = sort(unique(df[["clip"]]), method = "radix"))
df <- df[stats::complete.cases(df[c("s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("s1", "s2", "s3", "est1", "est2", "est3", "mix", "clip"))  # infinite values stop the run (registry/errors.yaml)

# %% Signals: one column per true source and per separated signal, samples in row order
REFS <- c("s1", "s2", "s3")
ESTS <- c("est1", "est2", "est3")
MIX <- "mix"
CLIP <- "clip"
PERMUTE <- TRUE
ZERO_MEAN <- TRUE
BSS <- TRUE
FLEN <- 512
if (length(ESTS) != length(REFS)) {
  cs_error("CS_E_INVALID_OPTION", option = "Separated signals", allowed = paste0(length(REFS), " columns, one per true source"), value = length(ESTS))
}
clips <- if (is.null(CLIP)) list(`all rows` = df) else split(df, df[[CLIP]], drop = TRUE)

# %% Scores per clip: permutation-invariant matching on SI-SDR, then SI-SDRi and BSS Eval
rows <- list()
n_permuted <- 0L
for (name in names(clips)) {
  g <- clips[[name]]
  R <- t(as.matrix(g[REFS])); storage.mode(R) <- "double"
  E <- t(as.matrix(g[ESTS])); storage.mode(E) <- "double"
  for (i in seq_along(REFS)) {
    s <- if (ZERO_MEAN) R[i, ] - mean(R[i, ]) else R[i, ]
    if (sum(s * s) == 0) cs_error("CS_E_UNDEFINED", what = "SI-SDR", reason = paste0("the true source ", REFS[i], " is silent in clip ", name))
  }
  m <- if (!is.null(MIX)) as.numeric(g[[MIX]]) else NULL
  r <- cs_sep_evaluate(R, E, m, zero_mean = ZERO_MEAN, bss = BSS, flen = FLEN, permute = PERMUTE)
  if (any(r$perm != seq_along(REFS))) n_permuted <- n_permuted + 1L
  for (i in seq_along(REFS)) {
    rows[[length(rows) + 1]] <- list(
      clip = name, source = REFS[i], estimate = ESTS[r$perm[i]], samples = ncol(R),
      si_sdr = r$si_sdr[i],
      si_sdri = if (!is.null(m)) r$si_sdri[i] else NULL,
      mixture_si_sdr = if (!is.null(m)) r$mixture_si_sdr[i] else NULL,
      sdr = if (BSS) r$sdr[i] else NULL,
      sir = if (BSS) r$sir[i] else NULL,
      sar = if (BSS) r$sar[i] else NULL,
      snr = r$snr[i]
    )
  }
}

mean_of <- function(key, source = NULL) {
  v <- unlist(lapply(rows, function(x) if (!is.null(x[[key]]) && (is.null(source) || x$source == source)) x[[key]] else NULL))
  if (length(v)) mean(v) else NULL
}

si <- vapply(rows, function(x) x$si_sdr, 0)
values <- list(
  n_clips = length(clips), n_sources = length(REFS), n_samples = nrow(df),
  si_sdr_mean = mean_of("si_sdr"), si_sdr_median = stats::median(si), si_sdr_min = min(si),
  si_sdri_mean = mean_of("si_sdri"), mixture_si_sdr_mean = mean_of("mixture_si_sdr"),
  sdr_mean = mean_of("sdr"), sir_mean = mean_of("sir"), sar_mean = mean_of("sar"), snr_mean = mean_of("snr"),
  n_permuted = n_permuted, filter_length = if (BSS) FLEN else NULL
)
for (c in REFS) {
  for (key in c("si_sdr", "si_sdri", "sdr", "sir", "sar", "snr")) {
    v <- mean_of(key, c)
    if (!is.null(v)) values[[sprintf("%s[%s]", key, c)]] <- v
  }
}

# %% Artifact: one row per clip and source
out <- cs_ml_out_dir("target/academy-parity/run-8142/evaluate.separation/three_sources_mixture/out-r")
num_or_na <- function(key) vapply(rows, function(x) if (is.null(x[[key]])) NA_real_ else as.numeric(x[[key]]), 0)
art <- data.frame(
  clip = vapply(rows, function(x) x$clip, ""), source = vapply(rows, function(x) x$source, ""),
  estimate = vapply(rows, function(x) x$estimate, ""), samples = vapply(rows, function(x) as.integer(x$samples), 0L),
  si_sdr = num_or_na("si_sdr"), si_sdri = num_or_na("si_sdri"), mixture_si_sdr = num_or_na("mixture_si_sdr"),
  sdr = num_or_na("sdr"), sir = num_or_na("sir"), sar = num_or_na("sar"), snr = num_or_na("snr"),
  stringsAsFactors = FALSE
)
nanoparquet::write_parquet(art, file.path(out, "separation.parquet"))

# %% Result
cols <- list(list(key = "clip", label = "Clip"), list(key = "source", label = "True source"), list(key = "estimate", label = "Matched estimate"),
             list(key = "si_sdr", label = "SI-SDR (dB)", type = "number"))
if (!is.null(MIX)) cols <- c(cols, list(list(key = "si_sdri", label = "SI-SDRi (dB)", type = "number"), list(key = "mixture_si_sdr", label = "Mixture SI-SDR (dB)", type = "number")))
if (BSS) cols <- c(cols, list(list(key = "sdr", label = "SDR (dB)", type = "number"), list(key = "sir", label = "SIR (dB)", type = "number"), list(key = "sar", label = "SAR (dB)", type = "number")))
cols <- c(cols, list(list(key = "snr", label = "SNR (dB)", type = "number")))
keys <- vapply(cols, function(c) c$key, "")
table_rows <- lapply(rows[seq_len(min(500, length(rows)))], function(x) stats::setNames(lapply(keys, function(k) x[[k]]), keys))
tables <- list(list(key = "scores", title = "Scores by clip and source", columns = cols, rows = table_rows))
fin <- function(v) if (is.finite(v)) v else NA_real_
kind <- character(0); src <- character(0); val <- numeric(0)
for (x in rows) {
  if (!is.null(MIX)) { kind <- c(kind, "Mixture"); src <- c(src, x$source); val <- c(val, fin(x$mixture_si_sdr)) }
  kind <- c(kind, "Separated"); src <- c(src, x$source); val <- c(val, fin(x$si_sdr))
}
charts <- list(cs_chart("si_sdr", "cleveland-dot", paste0("SI-SDR by source", if (!is.null(MIX)) ": mixture and separated" else ""), list(
  category = cs_col("True source", src, "categorical", REFS),
  value = cs_col("SI-SDR (dB)", val, "numeric"),
  group = cs_col("Signal", kind, "categorical", if (!is.null(MIX)) c("Mixture", "Separated") else c("Separated"))
), note = if (!is.null(MIX)) "Mean over clips. The gap between the dots is SI-SDRi, the gain over the unseparated mixture." else "Mean over clips; higher is better."))
if (BSS) {
  metric <- character(0); msrc <- character(0); mval <- numeric(0)
  for (x in rows) {
    for (pair in list(c("sdr", "SDR"), c("sir", "SIR"), c("sar", "SAR"))) {
      metric <- c(metric, pair[2]); msrc <- c(msrc, x$source); mval <- c(mval, fin(x[[pair[1]]]))
    }
  }
  charts[[2]] <- cs_chart("bss_eval", "cleveland-dot", "BSS Eval by source", list(
    category = cs_col("True source", msrc, "categorical", REFS),
    value = cs_col("dB", mval, "numeric"),
    group = cs_col("Metric", metric, "categorical", c("SDR", "SIR", "SAR"))
  ), note = "SDR counts every error; SIR only leakage from the other sources; SAR only artifacts the separation added.")
}
assumptions <- list(
  list(key = "aligned", label = "Signals are aligned in time", status = "info",
       detail = "Rows are read as samples in time order; a delay between a source and its estimate lowers SI-SDR."),
  list(key = "silent_reference", label = "No silent sources", status = "pass", detail = "Every true source varies in every clip."),
  list(key = "same_count", label = "One estimate per source", status = "pass",
       detail = paste0(length(ESTS), " separated signals for ", length(REFS), " true sources",
                       if (PERMUTE) sprintf("; matching reordered them in %d of %d clips.", n_permuted, length(clips)) else ", paired in column order."))
)
stats_list <- list(list(key = "si_sdr_mean", label = "Mean SI-SDR (dB)", value = values$si_sdr_mean))
if (!is.null(MIX)) stats_list[[length(stats_list) + 1]] <- list(key = "si_sdri_mean", label = "Mean SI-SDRi (dB)", value = values$si_sdri_mean)
if (BSS) {
  stats_list <- c(stats_list, list(list(key = "sdr_mean", label = "Mean SDR (dB)", value = values$sdr_mean),
                                   list(key = "sir_mean", label = "Mean SIR (dB)", value = values$sir_mean),
                                   list(key = "sar_mean", label = "Mean SAR (dB)", value = values$sar_mean)))
}
stats_list[[length(stats_list) + 1]] <- list(key = "snr_mean", label = "Mean SNR (dB)", value = values$snr_mean)
cs_publish(list(
  title = "Source separation metrics (SI-SDR, SDR, SIR, SAR)",
  engine = cs_engine_info("codesplashr", "nanoparquet"),
  n = nrow(df),
  summary = sprintf("Mean SI-SDR %.1f dB over %d clip(s) and %d source(s).", values$si_sdr_mean, length(clips), length(REFS)),
  statistics = stats_list,
  tables = tables,
  assumptions = assumptions,
  charts = charts,
  values = values,
  warnings = warnings,
  artifacts = list(list(key = "separation", path = file.path(out, "separation.parquet"), format = "parquet"))
))

Sources

  • Le Roux J, Wisdom S, Erdogan H, Hershey JR (2019). SDR — half-baked or well done? ICASSP 2019, 626–630.
  • Vincent E, Gribonval R, Févotte C (2006). Performance measurement in blind audio source separation. IEEE Transactions on Audio, Speech, and Language Processing 14(4):1462–1469.
  • Raffel C, McFee B, Humphrey EJ, et al. (2014). mir_eval: a transparent implementation of common MIR metrics. ISMIR 2014.
  • Yu D, Kolbæk M, Tan Z-H, Jensen J (2017). Permutation invariant training of deep models for speaker-independent multi-talker speech separation. ICASSP 2017, 241–245.
  • Kolbæk M, Yu D, Tan Z-H, Jensen J (2017). Multitalker speech separation with utterance-level permutation invariant training of deep recurrent neural networks. IEEE/ACM TASLP 25(10):1901–1913.

From the CodeSplash method registry · evaluate.separation v1.0.1.