Skip to main content

🔍 Data Leakage Audit

This page documents the full audit of the AstroSpectro feature set for data leakage — any situation where a feature provides information about the target label that would not be available at inference time, or that introduces a circularity in the training process.

Why this page exists

The spectro_only=True architecture decision was made precisely to address leakage concerns. But as of run v6 (ST_350k_xgb_AFGKM_v6), the implementation allows some Gaia photometric features. This page documents exactly what is and is not considered leakage, and why.


Categories of features audited​

CategoryDescriptionLeakage risk
Spectroscopic line descriptorsEW, FWHM, prominence, depth, asymmetry of specific linesNone — derived from the spectrum directly
Continuum featuresslope, RMS, curvature across wavelength rangesNone — derived from spectrum
Spectral indicesLick indices, Dn4000, CaH2, G4300, etc.None — derived from spectrum
Color indices from spectrumsynthetic B-V, flux ratiosLow — derived from spectrum only
Gaia absolute magnitudesM_BP, M_G, M_RP (requires parallax)Medium — depends on Gaia cross-match quality
Gaia extinctionag_gspphotMedium — GSP-Phot derived, uses stellar model assumptions
Gaia colorsbp_g, g_rpLow — photometric, not spectroscopic
SNR per bandsnr_u, snr_g, snr_r, snr_i, snr_zHigh — correlates with spectral type and instrument sensitivity
Observation metadatara, dec, fiber_id, mjdHigh — positional/observational bias
FITS-level flagschi2, quality flagsHigh — correlates with data quality, not stellar physics

What was removed (spectro_only=True)​

The following feature categories are excluded when spectro_only=True is active in data_loader.py:

# Excluded feature families in spectro_only mode
EXCLUDED_FAMILIES = [
"snr_*", # SNR per photometric band (u/g/r/i/z)
"chi2_*", # Fit quality metrics
"ra", "dec", # Sky coordinates
"fiber_id", # Instrument fiber
"mjd", # Observation date
"heliocentric_correction",
"seeing",
# ... additional FITS metadata columns
]

These were removed after a feature importance analysis showed that SNR bands were appearing in the top features of an early run, creating a circularity: high-SNR spectra are easier to classify precisely because they're brighter, and brightness correlates with spectral type in the LAMOST selection function.


What remains — and the v6 clarification​

In run v6, the following 4 Gaia/photometric features are retained among the 99 entries of selected_features_ (the SHAP analysis groups exactly these columns as "Gaia / Photometric"):

FeatureTypeSHAP contributionStatus
M_BPGaia absolute magnitude (BP band)Minor⚠️ Review
M_GGaia absolute magnitude (G band)Minor⚠️ Review
M_RPGaia absolute magnitude (RP band)Minor⚠️ Review
ag_gspphotGaia GSP-Phot extinctionMinor⚠️ Review

These 4 features collectively account for 3.2% of total SHAP importance (shap_feature_importance.csv, category "Gaia / Photometric"; figure physical_vs_observational.png).

Two further broadband-colour columns, feature_bp_g (BP−G) and feature_g_rp (G−RP), are also among the selected features. The SHAP table files them under the "Colour" family as spectroscopic, so they are not included in the share above; they correlate strongly with Teff and are non-spectroscopic in origin. Both are absent from the partial validation run v7.

Status of the fix

Fixed in the code with an explicit list of Gaia/photometric columns (the 22 columns absent from v7). v7 was trained with this fix, but no complete spectro-only reference run exists yet. The v6 figures on this page therefore describe the reference run as it was trained, not the current code.

Are these leakage?​

Strictly speaking, no — they do not encode the label directly. However:

  1. M_BP, M_G, M_RP depend on Gaia parallax quality (RUWE filter applied via is_good_ruwe). Stars with poor parallax measurements are excluded from training, creating a selection bias toward nearby, well-measured stars.
  2. ag_gspphot is a GSP-Phot parameter derived using a stellar atmospheric model that implicitly assumes a spectral type — this is a mild circularity.
  3. bp_g, g_rp (not counted in the share above) are broadband colors that correlate strongly with Teff and therefore spectral type. They are not leakage per se, but they are non-spectroscopic.

What this means for the manuscript​

The claim "spectro_only=True" must be qualified in the RNAAS/A&A manuscript as:

"The pipeline is configured to exclude observational metadata and SNR-band features. Gaia absolute magnitudes and extinction are retained (contributing 3.2% of SHAP importance; two broad-band colour columns are also retained) since they represent physical stellar parameters, not instrumental artifacts."


Validation: no leakage detected for excluded features​

To verify the exclusion was effective:

  1. A control model was trained with the full feature set (including SNR bands and coordinates)
  2. SNR features appeared in the top-10 in that run
  3. After enforcing spectro_only=True, no SNR or metadata features appear in the selected feature set
  4. Balanced accuracy changed by less than 0.5% — confirming the excluded features were not informationally critical, just spuriously correlated

Actionable items before RNAAS submission​

  • Clarify the definition of spectro_only=True in the manuscript methods section
  • Explicitly state that M_BP, M_G, M_RP and ag_gspphot are retained (3.2% SHAP), together with the broadband colours bp_g and g_rp
  • Run a complete spectro-only reference run with the fixed code (v7 was trained with the fix but is partial) for a clean comparison with v6
  • Update spectro-only-mode.mdx to reflect the v6 definition