coelho_summary_path <- "data/coelho-basis-benchmark-summary.csv"
coelho_bench <- read.csv(coelho_summary_path, stringsAsFactors = FALSE)Spectral basis benchmark
The figure below uses the bundled demo spectra as the true basis, then generates a synthetic mixture matrix from them. That gives us a controlled comparison in which the target basis is known and both SpectralUnmix and NMF::nmf() can be compared on the same problem.
knitr::include_graphics("images/coelho-basis-benchmark.png")
coelho_bench$reconstruction_mse <- signif(coelho_bench$reconstruction_mse, 4)
coelho_bench$basis_mse <- signif(coelho_bench$basis_mse, 4)
knitr::kable(coelho_bench, caption = "Coelho basis benchmark summary.")| method | reconstruction_mse | basis_mse | iterations | converged |
|---|---|---|---|---|
| SpectralUnmix | 1e-07 | 0.001256 | 2000 | FALSE |
| NMF | 1e-07 | 0.001300 | NA | NA |
What we are testing here
The test suite verifies three things:
spectral_unmix()recovers a noise-free low-rank factorization with small reconstruction and component-spectrum error.spectral_unmix()is competitive withNMF::nmf(method = "lee")on the same toy problem after matching fitted components to the reference ordering.- early stopping and convergence bookkeeping are exposed through
loss,niter_run, andconverged.
Interpreting the diagnostics
fit$lossis the optimization history.fit$niter_runis the number of iterations actually executed.fit$convergedindicates whether early stopping triggered before the maximum iteration budget.