Skip to content
DraconiticResearch
Search Sources API
197,785 studies31 sourcesUpdated 4 min ago
PreprintCC BYChemRxiv

Quantifying Validation-Induced Optimism in Machine Learning for Food Spectroscopy: An Empirical Multi-Dataset Benchmark

  1. 1Department of Agricultural Science and Food Engineering, Lucian Blaga University of Sibiu, Dr. I. Ratiu Street 7–9, Sibiu, Sibiu, Romania, 550012

Abstract

Background: Evaluating machine-learning regression models in food spectroscopy using random row-wise cross-validation ignores hierarchical experimental structures (replicate scans, aliquot extractions, packaging batches, instruments, and harvest campaigns). While theoretical warnings caution against sample leakage, the chemometric literature lacks a multidataset empirical quantification of validation-induced optimism, its impact on model selection, and its underlying physical mechanisms. Methods: We executed an empirical multi-dataset benchmark across four benchmark food spectroscopy collections encompassing 12,706 source spectra/records, with 6,376 spectra evaluated in primary regression workflows: Cargill corn near-infrared (NIR; n = 240 spectra across 80 physical grain samples and 3 spectrometers; targets: moisture and protein), edible vegetable oils Raman (Gilbraith , 2024; n = 215 spectra across 52 distinct reference titration determinations; target: peroxide value), mango fruit dry matter NIR (Anderson , 2020; n = 4,233 calibration spectra across 5 cultivars and n = 1,448 external harvest season spectra; target: dry matter content), and Tecator meat NIR (n = 240 spectra with 24 duplicate pairs [48 rows participating in identical pairs], leaving 216 unique spectral profiles; targets: fat and moisture). Six regression algorithms—partial least squares (PLS), Ridge regression, support vector regression (SVR-RBF), Random Forest, XGBoost, and k-nearest neighbours (kNN, serving as a diagnostic sentinel)—were evaluated across four hierarchical validation tiers: Level 1 (random row-wise cross-validation), Level 2 (sample-aware group cross-validation, reference-valuegrouped validation, or deduplicated validation), Level 3 (cultivar-aware validation), and Level 4 (external instrument and seasonal holdout). Model specifications were held fixed across validation tiers to isolate validation design as the sole manipulated factor, and all spectral standardisation was strictly fitted within training partitions to eliminate unsupervised leakage. Results: Transitioning from random row-wise to structured validation systematically eroded apparent predictive performance across all 36 random-to-structured model–task contrasts, yielding a median validation-induced optimism ΔR2 of 0.0170 (mean 0.3290, interquartile range [0.0084, 0.3985]) and a median root-mean-square error inflation ratio (RR_RMSE = RMSE_structured / RMSE_random) of 1.1395 (mean 1.4277, IQR [1.0417, 1.4374], range [0.9406, 5.2645]). Degradation was especially pronounced under external domain transfer (median ΔR2 = 0.6399, median RR_RMSE = 1.8199). In edible oils containing replicate scans sharing identical titration reference values, random cross-validation produced catastrophic performance inflation for non-linear models: kNN collapsed from an apparent R2 of 0.8865 (RMSE 5.40 meq O2/kg) to −2.1443 (RMSE 28.43 meq O2/kg; RR_RMSE = 5.265), and Random Forest collapsed from R2 = 0.8437 to −0.5806 (RR_RMSE = 3.180). This replicate leakage completely inverted algorithm rankings (Spearman ρ = −0.886, p = 0.019; Kendall τ = −0.733, p = 0.056). Algorithm robustness under external transfer was domain-specific: Ridge was the most resilient model under Mango seasonal transfer (R2 = 0.6690, compared to R2 ≈ 0.13–0.17 for tree ensembles), whereas uncalibrated Corn instrument transfer caused severe degradation in linear models (Ridge R2 = −30.04, PLS R2 = −37.05) due to uncorrected spectrometer baseline shifts. In contrast, non-linear models exhibited smaller relative degradation under sensor transfer. Cross-partition nearest-neighbour spectral similarity dropped by up to 0.0164 under domain transfer. Across tasks, this similarity drop showed an exploratory positive association with kNN error inflation (Pearson r = 0.739, Spearman ρ = 0.912), consistent with a spectral-proximity mechanism whereby high optical similarity enables flexible models to interpolate training points rather than learning transferable chemical relationships. Conclusions: Random row-wise validation creates severe validation-induced optimism, distorts algorithm rankings, and rewards models that memorise experimental artefacts. Reporting standards, mandatory specimen-level split manifests, and the routine inclusion of kNN as a diagnostic canary are essential to restore methodological integrity and field deployability to machine learning in food analysis.

Related

  1. Quantifying U–H covalency in a series of uranyl borohydrides using 1H NMR spectroscopy
    C. A. U. Kawshalya Kumarihami, Nathan R. Loutsch, Nadia Arsenijevic +3
    Chemical sciencePeer-reviewedCC BY-NCFull textOrganic chemistryEurope PMC
  2. Hybrid-CatBoost: an empirical comparison of molecular representations for aqueous-solubility prediction on the TDC benchmark
    Ruming Li
    ChemRxivPreprintCC BYFull textGeneral chemistryChemRxiv
  3. Donor-level validation of Raman spectroscopy for breast cancer subtype classification
    ali khoshnami, Seyedeh Rahemeh Amiri
    ChemRxivPreprintLicence not statedGeneral chemistryChemRxiv
  4. A Molecular Generation–Validation Workflow Combining Reversible Junction Tree Reinforcement Learning and Semi-empirical Quantum Chemistry: A Case Study on Molecular Solar Thermal Fuels
    Qingyu Zhu, Ryan Lingg, Reuben Szabo +2
    ChemRxivPreprintCC BYFull textMaterials & polymersChemRxiv
  5. Empirical Validation of SNR-Dependent Deep Learning Architectures for Label-Free Super-Resolution in Optical Microscopy
    Shiraz S. Kaderuppan, Jonathan D. Mar, Andrew C. Irvine +4
    NanomaterialsPeer-reviewedCC BY 4.0Full textMaterials & polymersCrossrefEurope PMC
BibTeX
@misc{otto2026quantifying,
  title = {{Quantifying Validation-Induced Optimism in Machine Learning for Food Spectroscopy: An Empirical Multi-Dataset Benchmark}},
  author = {Ketney Otto},
  howpublished = {ChemRxiv},
  year = {2026},
  month = sep,
  doi = {10.26434/chemrxiv.15009168/v1},
  url = {https://chemrxiv.org/doi/full/10.26434/chemrxiv.15009168/v1},
  note = {CC BY},
}
RIS
TY  - UNPB
TI  - Quantifying Validation-Induced Optimism in Machine Learning for Food Spectroscopy: An Empirical Multi-Dataset Benchmark
AU  - Ketney Otto
PY  - 2026
DA  - 2026/09/21
PB  - ChemRxiv
DO  - 10.26434/chemrxiv.15009168/v1
UR  - https://chemrxiv.org/doi/full/10.26434/chemrxiv.15009168/v1
AB  - Background: Evaluating machine-learning regression models in food spectroscopy using random row-wise cross-validation ignores hierarchical experimental structures (replicate scans, aliquot extractions, packaging batches, instruments, and harvest campaigns). While theoretical warnings caution against sample leakage, the chemometric literature lacks a multidataset empirical quantification of validation-induced optimism, its impact on model selection, and its underlying physical mechanisms. Methods: We executed an empirical multi-dataset benchmark across four benchmark food spectroscopy collections encompassing 12,706 source spectra/records, with 6,376 spectra evaluated in primary regression workflows: Cargill corn near-infrared (NIR; n = 240 spectra across 80 physical grain samples and 3 spectrometers; targets: moisture and protein), edible vegetable oils Raman (Gilbraith , 2024; n = 215 spectra across 52 distinct reference titration determinations; target: peroxide value), mango fruit dry matter NIR (Anderson , 2020; n = 4,233 calibration spectra across 5 cultivars and n = 1,448 external harvest season spectra; target: dry matter content), and Tecator meat NIR (n = 240 spectra with 24 duplicate pairs [48 rows participating in identical pairs], leaving 216 unique spectral profiles; targets: fat and moisture). Six regression algorithms—partial least squares (PLS), Ridge regression, support vector regression (SVR-RBF), Random Forest, XGBoost, and k-nearest neighbours (kNN, serving as a diagnostic sentinel)—were evaluated across four hierarchical validation tiers: Level 1 (random row-wise cross-validation), Level 2 (sample-aware group cross-validation, reference-valuegrouped validation, or deduplicated validation), Level 3 (cultivar-aware validation), and Level 4 (external instrument and seasonal holdout). Model specifications were held fixed across validation tiers to isolate validation design as the sole manipulated factor, and all spectral standardisation was strictly fitted within training partitions to eliminate unsupervised leakage. Results: Transitioning from random row-wise to structured validation systematically eroded apparent predictive performance across all 36 random-to-structured model–task contrasts, yielding a median validation-induced optimism ΔR2 of 0.0170 (mean 0.3290, interquartile range [0.0084, 0.3985]) and a median root-mean-square error inflation ratio (RR_RMSE = RMSE_structured / RMSE_random) of 1.1395 (mean 1.4277, IQR [1.0417, 1.4374], range [0.9406, 5.2645]). Degradation was especially pronounced under external domain transfer (median ΔR2 = 0.6399, median RR_RMSE = 1.8199). In edible oils containing replicate scans sharing identical titration reference values, random cross-validation produced catastrophic performance inflation for non-linear models: kNN collapsed from an apparent R2 of 0.8865 (RMSE 5.40 meq O2/kg) to −2.1443 (RMSE 28.43 meq O2/kg; RR_RMSE = 5.265), and Random Forest collapsed from R2 = 0.8437 to −0.5806 (RR_RMSE = 3.180). This replicate leakage completely inverted algorithm rankings (Spearman ρ = −0.886, p = 0.019; Kendall τ = −0.733, p = 0.056). Algorithm robustness under external transfer was domain-specific: Ridge was the most resilient model under Mango seasonal transfer (R2 = 0.6690, compared to R2 ≈ 0.13–0.17 for tree ensembles), whereas uncalibrated Corn instrument transfer caused severe degradation in linear models (Ridge R2 = −30.04, PLS R2 = −37.05) due to uncorrected spectrometer baseline shifts. In contrast, non-linear models exhibited smaller relative degradation under sensor transfer. Cross-partition nearest-neighbour spectral similarity dropped by up to 0.0164 under domain transfer. Across tasks, this similarity drop showed an exploratory positive association with kNN error inflation (Pearson r = 0.739, Spearman ρ = 0.912), consistent with a spectral-proximity mechanism whereby high optical similarity enables flexible models to interpolate training points rather than learning transferable chemical relationships. Conclusions: Random row-wise validation creates severe validation-induced optimism, distorts algorithm rankings, and rewards models that memorise experimental artefacts. Reporting standards, mandatory specimen-level split manifests, and the routine inclusion of kNN as a diagnostic canary are essential to restore methodological integrity and field deployability to machine learning in food analysis.
ER  -